crashanalysis/crashanalyser/com.nokia.s60tools.crashanalyser/src/com/nokia/s60tools/crashanalyser/ui/editors/MultiPageEditor.java
changeset 4 615035072f7e
parent 0 5ad7ad99af01
child 16 72f198be1c1d
equal deleted inserted replaced
3:431bbaccaec8 4:615035072f7e
    27 import org.eclipse.ui.*;
    27 import org.eclipse.ui.*;
    28 import org.eclipse.ui.ide.FileStoreEditorInput;
    28 import org.eclipse.ui.ide.FileStoreEditorInput;
    29 import org.eclipse.ui.part.MultiPageEditorPart;
    29 import org.eclipse.ui.part.MultiPageEditorPart;
    30 import com.nokia.s60tools.crashanalyser.data.ErrorLibrary;
    30 import com.nokia.s60tools.crashanalyser.data.ErrorLibrary;
    31 import com.nokia.s60tools.crashanalyser.files.*;
    31 import com.nokia.s60tools.crashanalyser.files.*;
       
    32 import com.nokia.s60tools.crashanalyser.files.SummaryFile.ContentType;
    32 import com.nokia.s60tools.crashanalyser.interfaces.*;
    33 import com.nokia.s60tools.crashanalyser.interfaces.*;
    33 import com.nokia.s60tools.crashanalyser.resources.ImageKeys;
    34 import com.nokia.s60tools.crashanalyser.resources.ImageKeys;
    34 import com.nokia.s60tools.crashanalyser.resources.ImageResourceManager;
    35 import com.nokia.s60tools.crashanalyser.resources.ImageResourceManager;
    35 import com.nokia.s60tools.crashanalyser.model.*;
    36 import com.nokia.s60tools.crashanalyser.model.*;
    36 import java.io.*;
    37 import java.io.*;
    37 
    38 
    38 /**
    39 /**
    39  * A Crash Visualiser editor. Editor contains four tab pages:
    40  * A Crash Visualiser editor. Editor contains seven tab pages:
    40  * Crash Data, Advanced, Errors & Warnings and XML.
    41  * General, Call Stack, Codesegments, Registers, Traces, Errors & Warnings and XML.
    41  * 
    42  * 
    42  * Crash Data page contains summary data of the crash and crash reason
    43  * Summary page contains summary data of the crash and crash reason
    43  * and description. Crash Data page also contain stack data if available.
    44  * and description. 
    44  * 
    45  * 
    45  * Advanced page contains more advanced details about the crash, such as 
    46  * Call Stack page contains call stack data if available. Codesegments page
    46  * registers values, code segments, event log and cpsr details.
    47  * contains crash time loaded codesegments. Registers page has register
       
    48  * values and CPSR details. Traces page has OST traces and event log.
    47  * 
    49  * 
    48  * Errors & Warnings page contains all error and warning messages which 
    50  * Errors & Warnings page contains all error and warning messages which 
    49  * may have occurred during the xml file creation.
    51  * may have occurred during the xml file creation.
    50  * 
    52  * 
    51  * XML tab page contains the raw xml data as an xml tree.
    53  * XML tab page contains the raw xml data as an xml tree.
    53  */
    55  */
    54 public class MultiPageEditor extends MultiPageEditorPart implements IResourceChangeListener, 
    56 public class MultiPageEditor extends MultiPageEditorPart implements IResourceChangeListener, 
    55 																	IErrorLibraryObserver {
    57 																	IErrorLibraryObserver {
    56 	// editor pages
    58 	// editor pages
    57 	private SummaryPage summaryPage;
    59 	private SummaryPage summaryPage;
    58 	private AdvancedPage advancedPage;
    60 	private CallStackPage callStackPage;	
       
    61 	private CodesegmentsPage codesegmentsPage;	
       
    62 	private RegistersPage registersPage;
       
    63 	private TracesPage tracesPage;
    59 	private ErrorPage errorPage;
    64 	private ErrorPage errorPage;
    60 	private XmlPage xmlPage;
    65 	private XmlPage xmlPage;
    61 	
    66 	
    62 	// editor data consists of either crashFile or summaryFile
    67 	// editor data consists of either crashFile or summaryFile
    63 	private CrashFile crashFile = null;
    68 	private CrashFile crashFile = null;
    64 	private SummaryFile summaryFile = null;
    69 	private SummaryFile summaryFile = null;
    65 	
    70 	
    66 	private ErrorLibrary errorLibrary = null;
    71 	private ErrorLibrary errorLibrary = null;
    67 	private String crashFilePath = "";
    72 	private String crashFilePath = "";
    68 	static final int ERROR_PAGE_INDEX = 2;
    73 	static final int ERROR_PAGE_INDEX = 5;
    69 	
    74 	
    70 	public MultiPageEditor() {
    75 	public MultiPageEditor() {
    71 		super();
    76 		super();
    72 		ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
    77 		ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
    73 	}
    78 	}
    74 	
    79 	
    75 	/**
    80 	/**
    76 	 * Creates Crash Data page
    81 	 * Creates General page
    77 	 */
    82 	 */
    78 	void createSummaryPage() {
    83 	void createSummaryPage() {
    79 		summaryPage = new SummaryPage();
    84 		summaryPage = new SummaryPage();
    80 		
    85 		
    81 		// output.crashxml is opened via CrashAnalyser View
    86 		// output.crashxml is opened via CrashAnalyser View
    82 		if (crashFile != null) {
    87 		if (crashFile != null) {
    83 			int index = 
    88 			int index = 
    84 				addPage(summaryPage.createPage(new Composite(getContainer(), SWT.NONE), crashFile));
    89 				addPage(summaryPage.createPage(new Composite(getContainer(), SWT.NONE), crashFile));
    85 			setPageText(index, "Crash Data");
    90 			setPageText(index, "General");
    86 		// Summary xml is opened via CrashAnalyser View
    91 		// Summary xml is opened via CrashAnalyser View
    87 		} else if (summaryFile != null) {
    92 		} else if (summaryFile != null) {
    88 			int index = 
    93 			int index = 
    89 				addPage(summaryPage.createPage(new Composite(getContainer(), SWT.NONE), summaryFile));
    94 				addPage(summaryPage.createPage(new Composite(getContainer(), SWT.NONE), summaryFile));
    90 			setPageText(index, "Crash Summary");
    95 			setPageText(index, "General");
    91 		// output.crashxml file opened from File > Open
    96 		// output.crashxml file opened from File > Open
    92 		} else {
    97 		} else {
    93 			int index = 
    98 			int index = 
    94 				addPage(summaryPage.createPage(new Composite(getContainer(), SWT.NONE)));
    99 				addPage(summaryPage.createPage(new Composite(getContainer(), SWT.NONE)));
    95 			setPageText(index, "Crash Data");
   100 			setPageText(index, "General");
    96 		}
   101 		}
    97 	}
   102 	}
    98 	
   103 	
    99 	/**
   104 	/**
   100 	 * Creates advanced page
   105 	 * Creates Call Stack page
   101 	 */
   106 	 */
   102 	void createAdvancedPage() {
   107 	void createCallStackPage() {
   103 		advancedPage = new AdvancedPage();
   108 		callStackPage = new CallStackPage();
   104 		
   109 		
   105 		// output.crashxml is opened via CrashAnalyser View
   110 		// output.crashxml is opened via CrashAnalyser View
   106 		if (crashFile != null) {
   111 		if (crashFile != null) {
   107 			int index = addPage(advancedPage.createPage(new Composite(getContainer(), SWT.NONE), crashFile));
   112 			if (crashFile.getContentType() == ContentType.CRASH) {
   108 			setPageText(index, "Advanced");
   113 				int index = 
   109 		// Summary xml is opened via CrashAnalyser View			
   114 					addPage(callStackPage.createPage(new Composite(getContainer(), SWT.NONE), crashFile));
   110 		} else if (summaryFile != null) {
   115 				setPageText(index, "Call Stack");
   111 			int index = addPage(advancedPage.createPage(new Composite(getContainer(), SWT.NONE), summaryFile));
   116 			}
   112 			setPageText(index, "Advanced");
   117 		// Summary xml is opened via CrashAnalyser View
   113 		// output.crashxml file opened from File > Open			
   118 		} else if (summaryFile != null) {
   114 		} else {
   119 			if (summaryFile.getContentType() == ContentType.CRASH) {
   115 			int index = addPage(advancedPage.createPage(new Composite(getContainer(), SWT.NONE)));
   120 				int index = 
   116 			setPageText(index, "Advanced");
   121 					addPage(summaryPage.createPage(new Composite(getContainer(), SWT.NONE), summaryFile));
   117 		}
   122 				setPageText(index, "Call Stack");
   118 	}
   123 			}
       
   124 		// output.crashxml file opened from File > Open
       
   125 		} else {
       
   126 			int index = 
       
   127 				addPage(summaryPage.createPage(new Composite(getContainer(), SWT.NONE)));
       
   128 			setPageText(index, "Call Stack");
       
   129 		}
       
   130 	}
       
   131 
       
   132 	/**
       
   133 	 * Creates Call Stack page
       
   134 	 */
       
   135 	void createCodesegmentsPage() {
       
   136 		codesegmentsPage = new CodesegmentsPage();
       
   137 		
       
   138 		// output.crashxml is opened via CrashAnalyser View
       
   139 		if (crashFile != null) {
       
   140 			if (crashFile.getContentType() == ContentType.CRASH) {
       
   141 				int index = 
       
   142 					addPage(codesegmentsPage.createPage(new Composite(getContainer(), SWT.NONE), crashFile));
       
   143 				setPageText(index, "Code Segments");
       
   144 			}
       
   145 		// Summary xml is opened via CrashAnalyser View
       
   146 		} else if (summaryFile != null) {
       
   147 			if (summaryFile.getContentType() == ContentType.CRASH) {
       
   148 				int index = 
       
   149 					addPage(codesegmentsPage.createPage(new Composite(getContainer(), SWT.NONE), summaryFile));
       
   150 				setPageText(index, "Code Segments");
       
   151 			}
       
   152 		// output.crashxml file opened from File > Open
       
   153 		} else {
       
   154 			int index = 
       
   155 				addPage(codesegmentsPage.createPage(new Composite(getContainer(), SWT.NONE)));
       
   156 			setPageText(index, "Code Segments");
       
   157 		}
       
   158 	}
       
   159 
       
   160 	/**
       
   161 	 * Creates Registers page
       
   162 	 */
       
   163 	void createRegistersPage() {
       
   164 		registersPage = new RegistersPage();
       
   165 		
       
   166 		// output.crashxml is opened via CrashAnalyser View
       
   167 		if (crashFile != null) {
       
   168 			if (crashFile.getContentType() == ContentType.CRASH) {
       
   169 				int index = 
       
   170 					addPage(registersPage.createPage(new Composite(getContainer(), SWT.NONE), crashFile));
       
   171 				setPageText(index, "Registers");
       
   172 			}
       
   173 		// Summary xml is opened via CrashAnalyser View
       
   174 		} else if (summaryFile != null) {
       
   175 			if (summaryFile.getContentType() == ContentType.CRASH) {
       
   176 				int index = 
       
   177 					addPage(registersPage.createPage(new Composite(getContainer(), SWT.NONE), summaryFile));
       
   178 				setPageText(index, "Registers");
       
   179 			}
       
   180 		// output.crashxml file opened from File > Open
       
   181 		} else {
       
   182 			int index = 
       
   183 				addPage(registersPage.createPage(new Composite(getContainer(), SWT.NONE)));
       
   184 			setPageText(index, "Registers");
       
   185 		}
       
   186 	}
       
   187 
       
   188 	/**
       
   189 	 * Creates Traces page
       
   190 	 */
       
   191 	void createTracesPage() {
       
   192 		tracesPage = new TracesPage();
       
   193 		
       
   194 		// output.crashxml is opened via CrashAnalyser View
       
   195 		if (crashFile != null) {
       
   196 			if (crashFile.getContentType() == ContentType.CRASH) {
       
   197 				int index = 
       
   198 					addPage(tracesPage.createPage(new Composite(getContainer(), SWT.NONE), crashFile));
       
   199 				setPageText(index, "Traces");
       
   200 			}
       
   201 		// Summary xml is opened via CrashAnalyser View
       
   202 		} else if (summaryFile != null) {
       
   203 			if (summaryFile.getContentType() == ContentType.CRASH) {
       
   204 				int index = 
       
   205 					addPage(tracesPage.createPage(new Composite(getContainer(), SWT.NONE), summaryFile));
       
   206 				setPageText(index, "Traces");
       
   207 			}
       
   208 		// output.crashxml file opened from File > Open
       
   209 		} else {
       
   210 			int index = 
       
   211 				addPage(tracesPage.createPage(new Composite(getContainer(), SWT.NONE)));
       
   212 			setPageText(index, "Traces");
       
   213 		}
       
   214 	}
       
   215 
   119 	
   216 	
   120 	/**
   217 	/**
   121 	 * Creates Errors & Warnings page
   218 	 * Creates Errors & Warnings page
   122 	 */
   219 	 */
   123 	void createErrorPage() {
   220 	void createErrorPage() {
   124 		errorPage = new ErrorPage();
   221 		errorPage = new ErrorPage();
   125 		
   222 		
   126 		// output.crashxml is opened via CrashAnalyser View
   223 		// output.crashxml is opened via CrashAnalyser View
   127 		if (crashFile != null) {
   224 		if (crashFile != null) {
   128 			if (crashFile.containsErrorsOrWarnings()) {
   225 			if (crashFile.containsErrorsOrWarnings() && crashFile.getContentType() == ContentType.CRASH) {
   129 				int index = addPage(errorPage.createPage(new Composite(getContainer(), SWT.NONE), crashFile));
   226 				int index = addPage(errorPage.createPage(new Composite(getContainer(), SWT.NONE), crashFile));
   130 				setPageText(index, "Errors && Warnings");
   227 				setPageText(index, "Errors && Warnings");
   131 			}
   228 			}
   132 		// Summary xml is opened via CrashAnalyser View			
   229 		// Summary xml is opened via CrashAnalyser View			
   133 		} else if (summaryFile != null) {
   230 		} else if (summaryFile != null) {
   134 			if (summaryFile.containsErrorsOrWarnings()) {
   231 			if (summaryFile.containsErrorsOrWarnings() && summaryFile.getContentType() == ContentType.CRASH) {
   135 				int index = addPage(errorPage.createPage(new Composite(getContainer(), SWT.NONE), summaryFile));
   232 				int index = addPage(errorPage.createPage(new Composite(getContainer(), SWT.NONE), summaryFile));
   136 				setPageText(index, "Errors && Warnings");
   233 				setPageText(index, "Errors && Warnings");
   137 			}
   234 			}
   138 		// output.crashxml file opened from File > Open			
   235 		// output.crashxml file opened from File > Open			
   139 		} else {
   236 		} else {
   167 	/**
   264 	/**
   168 	 * Creates the pages of the multi-page editor.
   265 	 * Creates the pages of the multi-page editor.
   169 	 */
   266 	 */
   170 	protected void createPages() {
   267 	protected void createPages() {
   171 		createSummaryPage();
   268 		createSummaryPage();
   172 		createAdvancedPage();
   269 		createCallStackPage();
       
   270 		createCodesegmentsPage();
       
   271 		createRegistersPage();
       
   272 		createTracesPage();
       
   273 
       
   274 		//		createAdvancedPage();
   173 		createErrorPage();
   275 		createErrorPage();
   174 		createXmlPage();
   276 		createXmlPage();
   175 		
   277 		
   176 		// output.crashxml file was opened via File > Open
   278 		// output.crashxml file was opened via File > Open
   177 		// we need to read error library and CrashFile
   279 		// we need to read error library and CrashFile
   185 	public void errorLibraryReady() {
   287 	public void errorLibraryReady() {
   186 		Runnable refreshRunnable = new Runnable(){
   288 		Runnable refreshRunnable = new Runnable(){
   187 			public void run(){
   289 			public void run(){
   188 				crashFile = CrashFile.read(new File(crashFilePath), errorLibrary);
   290 				crashFile = CrashFile.read(new File(crashFilePath), errorLibrary);
   189 				summaryPage.setFile(crashFile);
   291 				summaryPage.setFile(crashFile);
   190 				advancedPage.setFile(crashFile);
   292 				callStackPage.setFile(crashFile);
       
   293 				codesegmentsPage.setFile(crashFile);
       
   294 				registersPage.setFile(crashFile);
       
   295 				tracesPage.setFile(crashFile);
   191 				if (crashFile.containsErrorsOrWarnings()) {
   296 				if (crashFile.containsErrorsOrWarnings()) {
   192 					errorPage.setFile(crashFile);
   297 					errorPage.setFile(crashFile);
   193 				} else {
   298 				} else {
   194 					removePage(ERROR_PAGE_INDEX);
   299 					removePage(ERROR_PAGE_INDEX);
   195 				}
   300 				}
   267 		} else {
   372 		} else {
   268 			
   373 			
   269 			// output.crashxml file opened from Crash Analyser Main View
   374 			// output.crashxml file opened from Crash Analyser Main View
   270 			if (editorInput instanceof CrashFile) {
   375 			if (editorInput instanceof CrashFile) {
   271 				crashFile = (CrashFile)editorInput;
   376 				crashFile = (CrashFile)editorInput;
   272 				fileName = crashFile.getFileName();
   377 				
       
   378 				if (crashFile.getThread() != null) {
       
   379 					fileName = crashFile.getThread().getFullName();
       
   380 				} else {
       
   381 					fileName = crashFile.getFileName();
       
   382 				}
       
   383 				
   273 				super.setTitleImage(ImageResourceManager.getImage(ImageKeys.DECODED_FILE));
   384 				super.setTitleImage(ImageResourceManager.getImage(ImageKeys.DECODED_FILE));
   274 			
   385 			
   275 			// Summary xml file opened from Crash Analyser Main View
   386 			// Summary xml file opened from Crash Analyser Main View
   276 			} else if (editorInput instanceof SummaryFile) {
   387 			} else if (editorInput instanceof SummaryFile) {
   277 				summaryFile = (SummaryFile)editorInput;
   388 				summaryFile = (SummaryFile)editorInput;
   278 				fileName = summaryFile.getFileName();
   389 				
       
   390 				if (summaryFile.getThread() != null) {
       
   391 					fileName = summaryFile.getThread().getFullName();
       
   392 				} else {
       
   393 					fileName = summaryFile.getFileName();
       
   394 				}
       
   395 				
   279 				super.setTitleImage(ImageResourceManager.getImage(ImageKeys.PARTIALLY_DECODED_FILE));
   396 				super.setTitleImage(ImageResourceManager.getImage(ImageKeys.PARTIALLY_DECODED_FILE));
   280 
   397 
   281 			// output.crashxml file opened from Carbide File menu
   398 			// output.crashxml file opened from Carbide File menu
   282 			} else {
   399 			} else {
   283 				crashFilePath = ((FileStoreEditorInput)editorInput).getURI().getPath();
   400 				crashFilePath = ((FileStoreEditorInput)editorInput).getURI().getPath();