crashanalysis/crashanalyser/com.nokia.s60tools.crashanalyser/src/com/nokia/s60tools/crashanalyser/ui/editors/XmlPage.java
changeset 0 5ad7ad99af01
child 16 72f198be1c1d
equal deleted inserted replaced
-1:000000000000 0:5ad7ad99af01
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 package com.nokia.s60tools.crashanalyser.ui.editors;
       
    19 
       
    20 import org.eclipse.swt.layout.GridLayout;
       
    21 import org.eclipse.swt.widgets.Composite;
       
    22 import org.eclipse.swt.layout.GridData;
       
    23 import org.eclipse.swt.SWT;
       
    24 import org.eclipse.swt.browser.*;
       
    25 import org.eclipse.ui.PlatformUI;
       
    26 
       
    27 import com.nokia.s60tools.crashanalyser.files.*;
       
    28 import com.nokia.s60tools.crashanalyser.resources.HelpContextIDs;
       
    29 
       
    30 /**
       
    31  * XML page in Crash Visualiser editor. 
       
    32  *
       
    33  */
       
    34 public class XmlPage {
       
    35 
       
    36 	Browser browserXml;
       
    37 	SummaryFile crashFile = null;
       
    38 
       
    39 	/**
       
    40 	 * Creates the page
       
    41 	 * @param parent composite
       
    42 	 * @param file summary file
       
    43 	 * @return composite
       
    44 	 */
       
    45 	public Composite createPage(Composite parent, SummaryFile file) {
       
    46 		crashFile = file;
       
    47 		return doCreatePage(parent);
       
    48 	}
       
    49 	
       
    50 	/**
       
    51 	 * Creates the page
       
    52 	 * @param parent composite
       
    53 	 * @return composite
       
    54 	 */
       
    55 	public Composite createPage(Composite parent) {
       
    56 		return doCreatePage(parent);
       
    57 	}
       
    58 	
       
    59 	/**
       
    60 	 * Creates all UI elements to the page
       
    61 	 * @param parent
       
    62 	 * @return composite
       
    63 	 */
       
    64 	Composite doCreatePage(Composite parent) {
       
    65 	
       
    66 		GridLayout layout = new GridLayout();
       
    67 		layout.numColumns = 1;
       
    68 		parent.setLayout(layout);
       
    69 		parent.setLayoutData(new GridData(GridData.FILL_BOTH));
       
    70 
       
    71 		browserXml = new Browser(parent, SWT.NONE);
       
    72 		if (crashFile != null)
       
    73 			browserXml.setUrl(crashFile.getFilePath());
       
    74 		
       
    75 		browserXml.setLayoutData(new GridData(GridData.FILL_BOTH));
       
    76 		
       
    77 		PlatformUI.getWorkbench().getHelpSystem().setHelp(browserXml,
       
    78 				HelpContextIDs.CRASH_ANALYSER_HELP_CRASH_VISUALISER);	
       
    79 		
       
    80 		return parent;
       
    81 	}
       
    82 	
       
    83 	/**
       
    84 	 * Loads data from given file into UI elements.
       
    85 	 * @param file crash file
       
    86 	 */
       
    87 	public void setFile(CrashFile file) {
       
    88 		if (file != null) {
       
    89 			crashFile = file;
       
    90 			browserXml.setUrl(crashFile.getFilePath());
       
    91 		}
       
    92 	}
       
    93 }