debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/Trace32WizardPage.java
changeset 0 fb279309251b
child 566 960058f9da89
child 569 369485fbe634
equal deleted inserted replaced
-1:000000000000 0:fb279309251b
       
     1 /*
       
     2 * Copyright (c) 2009 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 the License "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 package com.nokia.cdt.internal.debug.launch.wizard;
       
    18 
       
    19 import java.io.File;
       
    20 import java.text.MessageFormat;
       
    21 
       
    22 import org.eclipse.cdt.utils.ui.controls.ControlFactory;
       
    23 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
       
    24 import org.eclipse.jface.dialogs.Dialog;
       
    25 import org.eclipse.jface.wizard.WizardPage;
       
    26 import org.eclipse.swt.SWT;
       
    27 import org.eclipse.swt.events.SelectionAdapter;
       
    28 import org.eclipse.swt.events.SelectionEvent;
       
    29 import org.eclipse.swt.layout.GridData;
       
    30 import org.eclipse.swt.layout.GridLayout;
       
    31 import org.eclipse.swt.widgets.Button;
       
    32 import org.eclipse.swt.widgets.Combo;
       
    33 import org.eclipse.swt.widgets.Composite;
       
    34 import org.eclipse.swt.widgets.FileDialog;
       
    35 import org.eclipse.swt.widgets.Label;
       
    36 import org.eclipse.swt.widgets.Text;
       
    37 import org.eclipse.ui.PlatformUI;
       
    38 
       
    39 import com.nokia.cdt.debug.cw.symbian.SettingsData;
       
    40 import com.nokia.cpp.internal.api.utils.core.Check;
       
    41 
       
    42 import cwdbg.PreferenceConstants;
       
    43 
       
    44 public class Trace32WizardPage extends WizardPage {
       
    45     		
       
    46     private boolean isDisposed = false;
       
    47     
       
    48 	private Label t32BootConfigLabel;
       
    49 	private Text t32BootConfigFilePath;
       
    50 	private Button t32BootConfigFileBrowse;
       
    51 	private String t32CMMScript;
       
    52 	
       
    53 	private Combo processorsList;
       
    54 	private int selectedProcIndex;
       
    55 
       
    56 	private final ISummaryTextItemContainer summaryTextItemContainer;
       
    57 	
       
    58     public Trace32WizardPage(ISummaryTextItemContainer summaryTextItemContainer) {
       
    59         super(Messages.getString("Trace32WizardPage.0")); //$NON-NLS-1$
       
    60 		Check.checkArg(summaryTextItemContainer);
       
    61 		this.summaryTextItemContainer = summaryTextItemContainer;
       
    62         setPageComplete(false);
       
    63         setTitle(Messages.getString("Trace32WizardPage.0")); //$NON-NLS-1$
       
    64         setDescription(Messages.getString("Trace32WizardPage.1")); //$NON-NLS-1$
       
    65     }
       
    66     
       
    67     public void dispose() {
       
    68     	isDisposed = true;
       
    69     	t32CMMScript = t32BootConfigFilePath.getText().trim();
       
    70     	selectedProcIndex = processorsList.getSelectionIndex();
       
    71     	super.dispose();
       
    72     }
       
    73 
       
    74 	/*
       
    75      * @see IDialogPage#createControl(Composite)
       
    76      */
       
    77     public void createControl(Composite parent) {
       
    78         Composite composite = new Composite(parent, SWT.NULL);
       
    79         GridLayout layout = new GridLayout();
       
    80         layout.numColumns = 3;
       
    81         composite.setLayout(layout);
       
    82         
       
    83         GridData data = new GridData();
       
    84         composite.setLayoutData(data);
       
    85 
       
    86 		t32BootConfigLabel = new Label(composite, SWT.NONE);
       
    87 		t32BootConfigLabel.setText(Messages.getString("Trace32WizardPage.2")); //$NON-NLS-1$
       
    88 		data = new GridData();
       
    89 		data.horizontalSpan = 3;
       
    90 		t32BootConfigLabel.setLayoutData(data);
       
    91 		t32BootConfigLabel.setToolTipText(Messages.getString("Trace32WizardPage.3")); //$NON-NLS-1$
       
    92 
       
    93 		t32BootConfigFilePath = new Text(composite, SWT.BORDER);
       
    94 		data = new GridData(GridData.FILL_HORIZONTAL);	
       
    95 		data.horizontalSpan = 2;
       
    96 		t32BootConfigFilePath.setLayoutData(data);
       
    97 		t32BootConfigFilePath.setToolTipText(Messages.getString("Trace32WizardPage.3")); //$NON-NLS-1$
       
    98 		
       
    99 		t32BootConfigFileBrowse = ControlFactory.createPushButton(composite, Messages.getString("Trace32WizardPage.9")); //$NON-NLS-1$
       
   100 		t32BootConfigFileBrowse.addSelectionListener(new SelectionAdapter() {
       
   101 
       
   102 			public void widgetSelected(SelectionEvent evt) {
       
   103 				FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
       
   104 
       
   105 				dialog.setText(Messages.getString("Trace32WizardPage.4")); //$NON-NLS-1$
       
   106 				dialog.setFilterExtensions(new String[] {"*.cmm*", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$
       
   107 				dialog.setFilterNames(new String[] {Messages.getString("Trace32WizardPage.5"), Messages.getString("Trace32WizardPage.6")}); //$NON-NLS-1$ //$NON-NLS-2$
       
   108 
       
   109 				String result = dialog.open();
       
   110 				if (result != null && new File(result).exists()) {
       
   111 					t32BootConfigFilePath.setText(result);					
       
   112 				}
       
   113 			}
       
   114 		});
       
   115 
       
   116 		
       
   117 		final Label processorsLabel = new Label(composite, SWT.NONE);
       
   118 		processorsLabel.setText(Messages.getString("Trace32WizardPage.7")); //$NON-NLS-1$
       
   119 		data = new GridData();
       
   120 		data.horizontalSpan = 3;
       
   121 		processorsLabel.setLayoutData(data);
       
   122 		processorsLabel.setToolTipText(Messages.getString("Trace32WizardPage.8")); //$NON-NLS-1$
       
   123 
       
   124 		processorsList = new Combo(composite, SWT.READ_ONLY);
       
   125 		processorsList.setItems(new String[] { "ARM920T", "ARM926TEJ", "ARM1136EJ-S", "OMAP3xx", "OMAP15xx", "OMAP16xx", "OMAP24xx", "OMAP34xx", "Generic" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
       
   126 		processorsList.select(8); //by default, select the generic 
       
   127 		data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
       
   128 		data.horizontalSpan = 3;
       
   129 		processorsList.setLayoutData(data);
       
   130 		processorsList.setToolTipText(Messages.getString("Trace32WizardPage.8")); //$NON-NLS-1$
       
   131 
       
   132 		setControl(composite);
       
   133         Dialog.applyDialogFont(parent);
       
   134         setPageComplete(true);
       
   135     }
       
   136     
       
   137     void updateConfiguration(ILaunchConfigurationWorkingCopy config) {
       
   138     	if (isDisposed) {
       
   139     		if (t32CMMScript.length()>0 && new File(t32CMMScript).exists()) {
       
   140     			config.setAttribute(SettingsData.spn_Trace32Conn_BootScriptFile, t32CMMScript);
       
   141     		}    		
       
   142     		config.setAttribute(PreferenceConstants.J_PN_TargetProcessor, selectedProcIndex);
       
   143     	} else {    		
       
   144     		if ((t32BootConfigFilePath.getText().trim().length()>0) && (new File(t32BootConfigFilePath.getText().trim()).exists())) {
       
   145     			config.setAttribute(SettingsData.spn_Trace32Conn_BootScriptFile, t32BootConfigFilePath.getText());
       
   146     		}
       
   147     		config.setAttribute( PreferenceConstants.J_PN_TargetProcessor, processorsList.getSelectionIndex());
       
   148     	}
       
   149     }
       
   150     
       
   151     public void setVisible(boolean visible) {
       
   152     	super.setVisible(visible);
       
   153     	if (!visible) {
       
   154 			summaryTextItemContainer.putSummaryTextItem("T32InitScript",  //$NON-NLS-1$
       
   155     				MessageFormat.format("{0} {1}", new Object[] { //$NON-NLS-1$
       
   156     						Messages.getString("Trace32WizardPage.2"), //$NON-NLS-1$
       
   157     						t32BootConfigFilePath.getText() } ));
       
   158     		summaryTextItemContainer.putSummaryTextItem("TargetProcessor",  //$NON-NLS-1$
       
   159     				MessageFormat.format("{0} {1}", new Object[] { //$NON-NLS-1$
       
   160     						Messages.getString("Trace32WizardPage.7"), //$NON-NLS-1$
       
   161     						processorsList.getItem(processorsList.getSelectionIndex()) } ));
       
   162     	}
       
   163     }
       
   164     
       
   165     @Override
       
   166     public void performHelp() {
       
   167 		PlatformUI.getWorkbench().getHelpSystem().displayHelp(LaunchWizardHelpIds.WIZARD_TRACE32_PAGE);
       
   168     }
       
   169 }