builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/ROMBuilderTabComposite.java
branchC3_BUILDER_WORK
changeset 1706 3ecac009d20b
parent 1701 e82be937be91
child 1707 ddfcc3a97d22
equal deleted inserted replaced
1701:e82be937be91 1706:3ecac009d20b
     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.carbide.cdt.internal.builder.ui;
       
    18 
       
    19 import java.io.File;
       
    20 
       
    21 import org.eclipse.cdt.utils.ui.controls.ControlFactory;
       
    22 import org.eclipse.swt.SWT;
       
    23 import org.eclipse.swt.events.SelectionAdapter;
       
    24 import org.eclipse.swt.events.SelectionEvent;
       
    25 import org.eclipse.swt.layout.GridData;
       
    26 import org.eclipse.swt.layout.GridLayout;
       
    27 import org.eclipse.swt.widgets.Button;
       
    28 import org.eclipse.swt.widgets.Composite;
       
    29 import org.eclipse.swt.widgets.DirectoryDialog;
       
    30 import org.eclipse.swt.widgets.Label;
       
    31 import org.eclipse.swt.widgets.TabItem;
       
    32 import org.eclipse.swt.widgets.Text;
       
    33 
       
    34 import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration;
       
    35 import com.nokia.carbide.cdt.builder.project.IROMBuilderInfo;
       
    36 import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
       
    37 import com.nokia.cpp.internal.api.utils.ui.BrowseDialogUtils;
       
    38 
       
    39 /**
       
    40  * Arguments tab for the Carbide Build Configurations page
       
    41  *
       
    42  */
       
    43 public class ROMBuilderTabComposite extends Composite {
       
    44 
       
    45 	private Text cmdLineEdit;
       
    46 	private Text workingDirEdit;
       
    47 	private Button workingDirBrowse;
       
    48 
       
    49 	
       
    50 	public ROMBuilderTabComposite(TabItem tabItem) {
       
    51 		super(tabItem.getParent(), SWT.NONE);
       
    52 	}
       
    53 
       
    54 	public void createControls() {
       
    55 		setLayout(new GridLayout(3, false));
       
    56 
       
    57 		Label cmdLineLabel = new Label(this, SWT.NONE);
       
    58 		cmdLineLabel.setText(Messages.getString("CarbideRomBuilderTab.Cmd_Line")); //$NON-NLS-1$
       
    59 		cmdLineLabel.setToolTipText(Messages.getString("CarbideRomBuilderTab.Cmd_Line_Tool_Tip")); //$NON-NLS-1$
       
    60 
       
    61 		cmdLineEdit = new Text(this, SWT.BORDER);
       
    62 		cmdLineEdit.setToolTipText(Messages.getString("CarbideRomBuilderTab.BldfilesArgumentsToolTip")); //$NON-NLS-1$
       
    63 		cmdLineEdit.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
       
    64 
       
    65 		Label workingDirLabel = new Label(this, SWT.NONE);
       
    66 		workingDirLabel.setText(Messages.getString("CarbideRomBuilderTab.Working_Dir")); //$NON-NLS-1$
       
    67 		workingDirLabel.setToolTipText(Messages.getString("CarbideRomBuilderTab.Working_Dir_Tool_Tip")); //$NON-NLS-1$
       
    68 
       
    69 		workingDirEdit = new Text(this, SWT.BORDER);
       
    70 		workingDirEdit.setToolTipText(Messages.getString("CarbideRomBuilderTab.Working_Dir_Tool_Tip")); //$NON-NLS-1$
       
    71 		workingDirEdit.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
       
    72 
       
    73 		workingDirBrowse = ControlFactory.createPushButton(this, Messages.getString("CarbideRomBuilderTab.Browse")); //$NON-NLS-1$
       
    74 		workingDirBrowse.addSelectionListener(new SelectionAdapter() {
       
    75 			public void widgetSelected(SelectionEvent evt) {
       
    76 				DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.NONE);
       
    77 				BrowseDialogUtils.initializeFrom(dialog, workingDirEdit);
       
    78 
       
    79 				dialog.setText(Messages.getString("CarbideRomBuilderTab.Rom_Dir_Dialog_Title")); //$NON-NLS-1$
       
    80 				String result = dialog.open();
       
    81 				
       
    82 				if (result != null) {
       
    83 					workingDirEdit.setText(result);
       
    84 				} 
       
    85 			}
       
    86 		});
       
    87 	}
       
    88 	
       
    89 	public void initData(ICarbideBuildConfiguration buildConfig) {
       
    90 		IROMBuilderInfo romInfo = buildConfig.getROMBuildInfo();
       
    91 		cmdLineEdit.setText(romInfo.getCommandLine());
       
    92 		workingDirEdit.setText(romInfo.getWorkingDirectory());
       
    93 	}
       
    94 	
       
    95 	public boolean compareConfigurationSettings(ICarbideBuildConfiguration selectedConfig, boolean writeToConfig) {
       
    96 		boolean settingsEqual = true;
       
    97 		
       
    98 		IROMBuilderInfo existingInfo = selectedConfig.getROMBuildInfo();
       
    99 		settingsEqual = existingInfo.getCommandLine().equals(cmdLineEdit.getText()) &&
       
   100 		existingInfo.getWorkingDirectory().equals(workingDirEdit.getText());
       
   101 		
       
   102 		if (!settingsEqual && writeToConfig) {
       
   103 			existingInfo.setCommandLine(cmdLineEdit.getText());
       
   104 			existingInfo.setWorkingDirectory(workingDirEdit.getText());
       
   105 		}
       
   106 		
       
   107 		return settingsEqual;
       
   108 	}
       
   109 	
       
   110 	public void performDefaults(ISymbianSDK sdk) {
       
   111 		cmdLineEdit.setText(""); //$NON-NLS-1$
       
   112 		workingDirEdit.setText("C:\\"); //$NON-NLS-1$
       
   113 
       
   114 		// now set epoc32\rom folder in the sdk as the default working dir 
       
   115 		// this is most common folder that rom images are built from for most symbian kits..
       
   116 		String dir = sdk.getEPOCROOT() + "epoc32\\rom\\";  //$NON-NLS-1$
       
   117 		if (new File(dir).exists())
       
   118 			workingDirEdit.setText(dir);
       
   119 	}
       
   120 }