debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/ui/SophiaTargetInterfaceTab.java
branchRCL_2_4
changeset 828 17e718655d73
parent 825 50fdb7752268
child 830 ce9defbd72a6
child 831 57d9fe8bebac
equal deleted inserted replaced
825:50fdb7752268 828:17e718655d73
     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.ui;
       
    18 
       
    19 import com.nokia.cdt.debug.cw.symbian.SettingsData;
       
    20 import com.nokia.cdt.internal.debug.launch.LaunchPlugin;
       
    21 
       
    22 import org.eclipse.cdt.launch.ui.CLaunchConfigurationTab;
       
    23 import org.eclipse.core.runtime.CoreException;
       
    24 import org.eclipse.debug.core.ILaunchConfiguration;
       
    25 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
       
    26 import org.eclipse.jface.dialogs.Dialog;
       
    27 import org.eclipse.swt.SWT;
       
    28 import org.eclipse.swt.events.*;
       
    29 import org.eclipse.swt.graphics.Image;
       
    30 import org.eclipse.swt.layout.GridData;
       
    31 import org.eclipse.swt.layout.GridLayout;
       
    32 import org.eclipse.swt.widgets.*;
       
    33 import org.eclipse.ui.PlatformUI;
       
    34 
       
    35 import java.io.File;
       
    36 
       
    37 public class SophiaTargetInterfaceTab extends CLaunchConfigurationTab {
       
    38 
       
    39 	// Radio Buttons
       
    40 
       
    41 	// Boolean widgets
       
    42 	private Button viewMessages;
       
    43 	private Combo jtagClockCombo;
       
    44 	private Text text;
       
    45 	private Combo emulatorTypeCombo;
       
    46 
       
    47 	/* (non-Javadoc)
       
    48 	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
       
    49 	 */
       
    50 	public void createControl(Composite parent) {
       
    51 		Composite comp = new Composite(parent, SWT.NONE);
       
    52 		setControl(comp);
       
    53 		
       
    54 		PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), LaunchTabHelpIds.STOP_MODE_SOPHIA_CONNECTION);
       
    55 		
       
    56 		GridLayout topLayout = new GridLayout();
       
    57 		topLayout.numColumns = 2;
       
    58 		comp.setLayout(topLayout);
       
    59 
       
    60 		//createVerticalSpacer(comp, 2);
       
    61 		//createSymbolicsLoadingGroup(comp, 2);
       
    62 		//createVerticalSpacer(comp, 2);
       
    63 		//createBooleanGroup(comp, 2);
       
    64 
       
    65 		final Label sophiaTargetInterfaceLabel = new Label(comp, SWT.NONE);
       
    66 		sophiaTargetInterfaceLabel.setText(Messages.getString("SophiaTargetInterfaceTab.0")); //$NON-NLS-1$
       
    67 		
       
    68 		sophiaTargetInterfaceLabel.setToolTipText(Messages.getString("SophiaTargetInterfaceTab.10")); //$NON-NLS-1$
       
    69 		new Label(comp, SWT.NONE);
       
    70 
       
    71 		text = new Text(comp, SWT.BORDER);
       
    72 		text.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
       
    73 		text.setToolTipText(Messages.getString("SophiaTargetInterfaceTab.10")); //$NON-NLS-1$
       
    74 		text.addModifyListener(new ModifyListener() {
       
    75 			public void modifyText(ModifyEvent e) {
       
    76 				updateLaunchConfigurationDialog();
       
    77 			}
       
    78 		});
       
    79 
       
    80 		final Button browseButton = new Button(comp, SWT.NONE);
       
    81 		browseButton.addSelectionListener(new SelectionAdapter() {
       
    82 
       
    83 				public void widgetSelected(SelectionEvent evt) {
       
    84 					FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
       
    85 
       
    86 					dialog.setText(Messages.getString("SophiaTargetInterfaceTab.7")); //$NON-NLS-1$
       
    87 					dialog.setFilterExtensions(new String[] {"*.dll*", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$
       
    88 					dialog.setFilterNames(new String[] {Messages.getString("SophiaTargetInterfaceTab.8"), Messages.getString("SophiaTargetInterfaceTab.9")}); //$NON-NLS-1$ //$NON-NLS-2$
       
    89 
       
    90 					String result = dialog.open();
       
    91 					if (result != null && new File(result).exists()) {
       
    92 						text.setText(result);
       
    93 						updateLaunchConfigurationDialog();
       
    94 					}
       
    95 				}
       
    96 			});
       
    97 	
       
    98 		browseButton.setText(Messages.getString("SophiaTargetInterfaceTab.1")); //$NON-NLS-1$
       
    99 		
       
   100 		final Label jtagTypeLabel = new Label(comp, SWT.NONE);
       
   101 		jtagTypeLabel.setText(Messages.getString("SophiaTargetInterfaceTab.11")); //$NON-NLS-1$
       
   102 		jtagTypeLabel.setToolTipText(Messages.getString("SophiaTargetInterfaceTab.12")); //$NON-NLS-1$
       
   103 		new Label(comp, SWT.NONE);
       
   104 
       
   105 		emulatorTypeCombo = new Combo(comp, SWT.READ_ONLY);
       
   106 		emulatorTypeCombo.setItems(new String[] {Messages.getString("SophiaTargetInterfaceTab.13"), Messages.getString("SophiaTargetInterfaceTab.14"), Messages.getString("SophiaTargetInterfaceTab.15"), Messages.getString("SophiaTargetInterfaceTab.16"), Messages.getString("SophiaTargetInterfaceTab.17")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
       
   107 		emulatorTypeCombo.setText(Messages.getString("SophiaTargetInterfaceTab.13")); //$NON-NLS-1$
       
   108 		emulatorTypeCombo.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, false));
       
   109 		emulatorTypeCombo.setToolTipText(Messages.getString("SophiaTargetInterfaceTab.12")); //$NON-NLS-1$
       
   110 		
       
   111 		emulatorTypeCombo.addSelectionListener(new SelectionAdapter() {
       
   112 			public void widgetSelected(SelectionEvent e) {
       
   113 				updateLaunchConfigurationDialog();
       
   114 			}
       
   115 		});
       
   116 		
       
   117 		new Label(comp, SWT.NONE);
       
   118 		
       
   119 		final Label jtagRtckLabel = new Label(comp, SWT.NONE);
       
   120 		jtagRtckLabel.setText(Messages.getString("SophiaTargetInterfaceTab.19")); //$NON-NLS-1$
       
   121 		jtagRtckLabel.setToolTipText(Messages.getString("SophiaTargetInterfaceTab.20")); //$NON-NLS-1$
       
   122 		new Label(comp, SWT.NONE);
       
   123 
       
   124 		jtagClockCombo = new Combo(comp, SWT.READ_ONLY);
       
   125 		jtagClockCombo.setItems(new String[] {Messages.getString("SophiaTargetInterfaceTab.13"), Messages.getString("SophiaTargetInterfaceTab.22"), Messages.getString("SophiaTargetInterfaceTab.23"), Messages.getString("SophiaTargetInterfaceTab.24"), Messages.getString("SophiaTargetInterfaceTab.25")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
       
   126 		jtagClockCombo.setText(Messages.getString("SophiaTargetInterfaceTab.13")); //$NON-NLS-1$
       
   127 		jtagClockCombo.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, false));
       
   128 		jtagClockCombo.setToolTipText(Messages.getString("SophiaTargetInterfaceTab.20")); //$NON-NLS-1$
       
   129 		
       
   130 		jtagClockCombo.addSelectionListener(new SelectionAdapter() {
       
   131 			public void widgetSelected(SelectionEvent e) {
       
   132 				updateLaunchConfigurationDialog();
       
   133 			}
       
   134 		});
       
   135 		
       
   136 		new Label(comp, SWT.NONE);
       
   137 
       
   138 		viewMessages = new Button(comp, SWT.CHECK);
       
   139 		viewMessages.setLayoutData(new GridData());
       
   140 		viewMessages.setText(Messages.getString("SophiaTargetInterfaceTab.27")); //$NON-NLS-1$
       
   141 		viewMessages.setToolTipText(Messages.getString("SophiaTargetInterfaceTab.18")); //$NON-NLS-1$
       
   142 		
       
   143 		viewMessages.addSelectionListener(new SelectionAdapter() {
       
   144 			public void widgetSelected(SelectionEvent e) {
       
   145 				updateLaunchConfigurationDialog();
       
   146 			}
       
   147 		});
       
   148 		new Label(comp, SWT.NONE);
       
   149 
       
   150 		Dialog.applyDialogFont(parent);
       
   151 		checkControlState();
       
   152 	}
       
   153 
       
   154 
       
   155 	/* (non-Javadoc)
       
   156 	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
       
   157 	 */
       
   158 	public void setDefaults(ILaunchConfigurationWorkingCopy config) {
       
   159 	
       
   160 	}
       
   161 
       
   162 	/* (non-Javadoc)
       
   163 	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
       
   164 	 */
       
   165 	public void initializeFrom(ILaunchConfiguration configuration) {
       
   166 		try {
       
   167 			text.setText(configuration.getAttribute( SettingsData.spn_SophiaSTIConn_DllPath, "C:\\CarbideIF_ARM\\WTI.dll")); //$NON-NLS-1$
       
   168 			jtagClockCombo.setText(configuration.getAttribute( SettingsData.spn_SophiaSTIConn_JtagClock, "Auto")); //$NON-NLS-1$
       
   169 			viewMessages.setSelection(configuration.getAttribute( SettingsData.spn_SophiaSTIConn_LogOption, false));
       
   170 			emulatorTypeCombo.setText(configuration.getAttribute(SettingsData.spn_SophiaSTIConn_StiEmulatorType, Messages.getString("SophiaTargetInterfaceTab.13"))); //$NON-NLS-1$
       
   171 			checkControlState();
       
   172 			
       
   173 		} catch (CoreException e) {
       
   174 			LaunchPlugin.log(e);
       
   175 		}
       
   176 
       
   177 	}
       
   178 
       
   179 	/* (non-Javadoc)
       
   180 	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
       
   181 	 */
       
   182 	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
       
   183 
       
   184 		configuration.setAttribute( SettingsData.spn_SophiaSTIConn_DllPath, text.getText());
       
   185 		configuration.setAttribute( SettingsData.spn_SophiaSTIConn_JtagClock, jtagClockCombo.getText());
       
   186 		configuration.setAttribute( SettingsData.spn_SophiaSTIConn_LogOption, viewMessages.getSelection());
       
   187 		configuration.setAttribute( SettingsData.spn_SophiaSTIConn_StiEmulatorType, emulatorTypeCombo.getText());
       
   188 	}
       
   189 
       
   190 	/* (non-Javadoc)
       
   191 	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
       
   192 	 */
       
   193 	public String getName() {
       
   194 		return Messages.getString("SophiaTargetInterfaceTab.4"); //$NON-NLS-1$
       
   195 	}
       
   196 	/*
       
   197 	 * (non-Javadoc)
       
   198 	 * 
       
   199 	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
       
   200 	 */
       
   201 	public Image getImage() {
       
   202 		return LaunchImages.get(LaunchImages.IMG_VIEW_CONNECTION_TAB);
       
   203 	}
       
   204 
       
   205 	protected void checkControlState()
       
   206 	{
       
   207 	}
       
   208 	
       
   209 	public boolean isValid(ILaunchConfiguration config) {
       
   210 		
       
   211 		setErrorMessage(null);
       
   212 		setMessage(null);
       
   213 
       
   214 		boolean result = super.isValid(config);
       
   215 		if (result){
       
   216 			String pcPath = text.getText().trim();
       
   217 			if (pcPath.length() < 1) {
       
   218 				setErrorMessage(Messages.getString("SophiaTargetInterfaceTab.5")); //$NON-NLS-1$
       
   219 				return false;
       
   220 			} else {
       
   221 				if (!new File(pcPath).exists()) {
       
   222 					setErrorMessage(Messages.getString("SophiaTargetInterfaceTab.6")); //$NON-NLS-1$
       
   223 					result = false;
       
   224 				}
       
   225 			}
       
   226 		}
       
   227 		return result;
       
   228 	}
       
   229 
       
   230 	@Override
       
   231 	public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
       
   232 		super.activated(workingCopy);
       
   233 		
       
   234 		// forces page to get focus so that help works without having to select some control first.
       
   235 		getControl().setFocus();
       
   236 	}
       
   237 }