sysperfana/analyzetoolext/com.nokia.s60tools.analyzetool/src/com/nokia/s60tools/analyzetool/preferences/AnalyzeToolPreferencePage.java
changeset 6 f65f740e69f9
parent 1 1050670c6980
child 15 0367d2db2c06
equal deleted inserted replaced
5:844b047e260d 6:f65f740e69f9
     1 /*
     1 /*
     2  * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     3  * All rights reserved.
     3  * All rights reserved.
     4  * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5  * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6  * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    60 
    60 
    61 	/** Button to ask always. */
    61 	/** Button to ask always. */
    62 	Button askButton = null;
    62 	Button askButton = null;
    63 
    63 
    64 	/** Atool.exe path field. */
    64 	/** Atool.exe path field. */
    65 	Text atooDirText = null;
    65 	Text atoolDirText = null;
    66 
    66 
    67 	/** User specified atool.exe path. */
    67 	/** User specified atool.exe path. */
    68 	Label atoolDir = null;
    68 	Label atoolDir = null;
    69 
    69 
    70 	/** Atool.exe version field. */
    70 	/** Atool.exe version field. */
    90 
    90 
    91 	/** Button to use process data. */
    91 	/** Button to use process data. */
    92 	Button processButton = null;
    92 	Button processButton = null;
    93 
    93 
    94 	/** Button to refresh atool.exe version. */
    94 	/** Button to refresh atool.exe version. */
    95 	Button refeshAtoolVersion = null;
    95 	Button refreshAtoolVersion = null;
    96 
    96 
    97 	/** Radio group for report level. */
    97 	/** Radio group for report level. */
    98 	RadioGroupFieldEditor reportLevels = null;
    98 	RadioGroupFieldEditor reportLevels = null;
    99 
    99 
   100 	/** Button to use S60 file mode. */
   100 	/** Button to use S60 file mode. */
   119 	Button useUserSpecified = null;
   119 	Button useUserSpecified = null;
   120 
   120 
   121 	/** Button to verbose atool.exe output. */
   121 	/** Button to verbose atool.exe output. */
   122 	Button verboseButton = null;
   122 	Button verboseButton = null;
   123 
   123 
   124 	/** Button to select Tracing utility connection. */
   124 	/** Button to select TraceViewer connection. */
   125 	Button externalButton = null;
   125 	Button externalButton = null;
   126 
   126 
   127 	/** Button to select fast external data gathering mode */
   127 	/** Button to select fast external data gathering mode */
   128 	Button externalFastButton = null;
   128 	Button externalFastButton = null;
   129 
   129 
   130 	/** No items button. */
   130 	/** No items button. */
   131 	Button zeroButton;
   131 	Button zeroButton;
       
   132 
   132 
   133 
   133 	/**
   134 	/**
   134 	 * Constructor.
   135 	 * Constructor.
   135 	 */
   136 	 */
   136 	public AnalyzeToolPreferencePage() {
   137 	public AnalyzeToolPreferencePage() {
   141 
   142 
   142 	/**
   143 	/**
   143 	 * Checks preferences initial values if logging mode is not set to S60
   144 	 * Checks preferences initial values if logging mode is not set to S60
   144 	 * disables S60 data file name selections.
   145 	 * disables S60 data file name selections.
   145 	 */
   146 	 */
   146 	public final void chechInitValues() {
   147 	public final void checkInitValues() {
   147 		IPreferenceStore store = Activator.getPreferences();
   148 		IPreferenceStore store = Activator.getPreferences();
   148 		
   149 		
   149 		// get stored atool folder
   150 		// get stored atool folder
   150 		String atoolFolder = store.getString(Constants.ATOOL_FOLDER);
   151 		String atoolFolder = store.getString(Constants.ATOOL_FOLDER);
   151 		atoolVerLabel.setText(Constants.PREFS_ATOOL_VER_NOT_FOUND);
   152 		atoolVerLabel.setText(Constants.PREFS_ATOOL_VER_NOT_FOUND);
   152 
   153 
   153 		// if atool folder is set to point default atool location
   154 		// if atool folder is set to point default atool location
   154 		if (atoolFolder.equals(Constants.DEFAULT_ATOOL_FOLDER)) {
   155 		if (atoolFolder.equals(Constants.DEFAULT_ATOOL_FOLDER)) {
   155 
   156 
   156 			// check stored atool location exists
   157 			// check that stored atool location exists
   157 			java.io.File file = new java.io.File(atoolFolder);
   158 			java.io.File file = new java.io.File(atoolFolder);
   158 			if (file.exists()) { // if exists use this location and update
   159 			if (file.exists()) { // if exists use this location and update
   159 				// preference page buttons
   160 				// preference page buttons
   160 				useDefaultLocation.setSelection(false);
   161 				useDefaultLocation.setSelection(false);
   161 				store.setValue(Constants.USE_INTERNAL, false);
   162 				store.setValue(Constants.USE_INTERNAL, false);
   171 
   172 
   172 		}
   173 		}
   173 
   174 
   174 		// get atool.exe path and set it atool.exe path field
   175 		// get atool.exe path and set it atool.exe path field
   175 		String atoolPath = store.getString(Constants.USER_SELECTED_FOLDER);
   176 		String atoolPath = store.getString(Constants.USER_SELECTED_FOLDER);
   176 		atooDirText.setText(atoolPath);
   177 		atoolDirText.setText(atoolPath);
   177 
   178 
   178 		// update preference page buttons
   179 		// update preference page buttons
   179 		handleDefaultLocationChange();
   180 		handleDefaultLocationChange();
   180 
   181 
   181 		// update atool.exe version number
   182 		// update atool.exe version number
   182 		if (useDefaultLocation.getSelection()) {
   183 		if (useDefaultLocation.getSelection()) {
   183 			updateAtoolVersion(null);
   184 			updateAtoolVersion(null);
   184 		} else {
   185 		} else {
   185 			updateAtoolVersion(atooDirText.getText());
   186 			updateAtoolVersion(atoolDirText.getText());
   186 		}
   187 		}
   187 
   188 
   188 		// get logging mode and update buttons
   189 		// get logging mode and update buttons
   189 		String fileMode = store.getString(Constants.LOGGING_MODE);
   190 		String fileMode = store.getString(Constants.LOGGING_MODE);
   190 		setGroupButtons(fileMode);
   191 		setGroupButtons(fileMode);
   217 			// enable spinner and set stored callstack size
   218 			// enable spinner and set stored callstack size
   218 			customButton.setSelection(true);
   219 			customButton.setSelection(true);
   219 			spinner.setEnabled(true);
   220 			spinner.setEnabled(true);
   220 			spinner.setSelection(callstackSize);
   221 			spinner.setSelection(callstackSize);
   221 		}
   222 		}
   222 
   223 		
   223 	}
   224 	}
   224 
   225 
   225 	/**
   226 	/**
   226 	 * Check if user entered folder location is available.
   227 	 * Check if user entered folder location is available.
   227 	 *
   228 	 *
   411 		atoolDir = new Label(compAtool, SWT.NONE);
   412 		atoolDir = new Label(compAtool, SWT.NONE);
   412 		atoolDir.setToolTipText(Constants.PREFS_SELECT_FOLDER);
   413 		atoolDir.setToolTipText(Constants.PREFS_SELECT_FOLDER);
   413 		atoolDir.setText(Constants.PREFS_ATOOL_PATH);
   414 		atoolDir.setText(Constants.PREFS_ATOOL_PATH);
   414 
   415 
   415 		// directory field
   416 		// directory field
   416 		atooDirText = new Text(compAtool, SWT.BORDER);
   417 		atoolDirText = new Text(compAtool, SWT.BORDER);
   417 		atooDirText.setLayoutData(new GridData(200, SWT.DEFAULT));
   418 		atoolDirText.setLayoutData(new GridData(200, SWT.DEFAULT));
   418 
   419 
   419 		// button which opens the folder selection dialog
   420 		// button which opens the folder selection dialog
   420 		browseButton = new Button(compAtool, SWT.NONE);
   421 		browseButton = new Button(compAtool, SWT.NONE);
   421 		browseButton.setToolTipText(Constants.PREFS_SELECT_FOLDER);
   422 		browseButton.setToolTipText(Constants.PREFS_SELECT_FOLDER);
   422 		browseButton.setText(Constants.PREFS_BROWSE);
   423 		browseButton.setText(Constants.PREFS_BROWSE);
   454 		GridData vergd13 = new GridData(GridData.FILL_HORIZONTAL);
   455 		GridData vergd13 = new GridData(GridData.FILL_HORIZONTAL);
   455 		vergd13.horizontalSpan = 2;
   456 		vergd13.horizontalSpan = 2;
   456 		atoolVerLabel.setLayoutData(vergd13);
   457 		atoolVerLabel.setLayoutData(vergd13);
   457 
   458 
   458 		// create button to refresh atool.exe version
   459 		// create button to refresh atool.exe version
   459 		refeshAtoolVersion = new Button(groupVersion, SWT.NONE);
   460 		refreshAtoolVersion = new Button(groupVersion, SWT.NONE);
   460 		refeshAtoolVersion.setText(Constants.PREFS_REFRESH_VERSION);
   461 		refreshAtoolVersion.setText(Constants.PREFS_REFRESH_VERSION);
   461 		refeshAtoolVersion.addListener(SWT.Selection, this);
   462 		refreshAtoolVersion.addListener(SWT.Selection, this);
   462 
   463 
   463 		// create data gathering group
   464 		// create data gathering group
   464 		createGatheringGroup();
   465 		createGatheringGroup();
   465 
   466 
   466 		// create callstack size group
   467 		// create callstack size group
   474 						{ Constants.PREFS_SHOW_TOPMOST,
   475 						{ Constants.PREFS_SHOW_TOPMOST,
   475 								Constants.REPORT_TOPMOST } },
   476 								Constants.REPORT_TOPMOST } },
   476 				getFieldEditorParent(), true);
   477 				getFieldEditorParent(), true);
   477 
   478 
   478 		addField(reportLevels);
   479 		addField(reportLevels);
   479 		chechInitValues();
   480 		
       
   481 		checkInitValues();
   480 		PlatformUI.getWorkbench().getHelpSystem().setHelp(super.getControl(),
   482 		PlatformUI.getWorkbench().getHelpSystem().setHelp(super.getControl(),
   481 				AnalyzeToolHelpContextIDs.ANALYZE_TOOL_VIEW_MEM_LEAKS);
   483 				AnalyzeToolHelpContextIDs.ANALYZE_TOOL_VIEW_MEM_LEAKS);
   482 
   484 
   483 	}
   485 	}
   484 
   486 
   486 	 * Handles atool.exe location selection changes Update corresponding buttons
   488 	 * Handles atool.exe location selection changes Update corresponding buttons
   487 	 * states.
   489 	 * states.
   488 	 */
   490 	 */
   489 	public final void handleDefaultLocationChange() {
   491 	public final void handleDefaultLocationChange() {
   490 		if (useDefaultLocation.getSelection()) {
   492 		if (useDefaultLocation.getSelection()) {
   491 			atooDirText.setEnabled(false);
   493 			atoolDirText.setEnabled(false);
   492 			browseButton.setEnabled(false);
   494 			browseButton.setEnabled(false);
   493 			atoolDir.setEnabled(false);
   495 			atoolDir.setEnabled(false);
   494 			useUserSpecified.setSelection(false);
   496 			useUserSpecified.setSelection(false);
   495 		} else {
   497 		} else {
   496 			atooDirText.setEnabled(true);
   498 			atoolDirText.setEnabled(true);
   497 			browseButton.setEnabled(true);
   499 			browseButton.setEnabled(true);
   498 			atoolDir.setEnabled(true);
   500 			atoolDir.setEnabled(true);
   499 			useUserSpecified.setSelection(true);
   501 			useUserSpecified.setSelection(true);
   500 		}
   502 		}
   501 	}
   503 	}
   502 
   504 	
   503 	/**
   505 	/*
   504 	 * Handles events.
   506 	 * (non-Javadoc)
   505 	 *
   507 	 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
   506 	 * @param event
       
   507 	 *            Preference page event
       
   508 	 */
   508 	 */
   509 	public final void handleEvent(final Event event) {
   509 	public final void handleEvent(final Event event) {
   510 		if (event.widget == browseButton) {
   510 		if (event.widget == browseButton) {
   511 			openFolderDialog();
   511 			openFolderDialog();
   512 		} else if (event.widget == externalButton || event.widget == externalFastButton || event.widget == askButton ) {
   512 		} else if (event.widget == externalButton || event.widget == externalFastButton || event.widget == askButton ) {
   516 			userButton.setEnabled(true);
   516 			userButton.setEnabled(true);
   517 			processButton.setEnabled(true);
   517 			processButton.setEnabled(true);
   518 		} else if (event.widget == useDefaultLocation
   518 		} else if (event.widget == useDefaultLocation
   519 				|| event.widget == atoolDir) {
   519 				|| event.widget == atoolDir) {
   520 			handleDefaultLocationChange();
   520 			handleDefaultLocationChange();
   521 		} else if (event.widget == refeshAtoolVersion) {
   521 		} else if (event.widget == refreshAtoolVersion) {
   522 			if (useDefaultLocation.getSelection()) {
   522 			if (useDefaultLocation.getSelection()) {
   523 				updateAtoolVersion(null);
   523 				updateAtoolVersion(null);
   524 			} else {
   524 			} else {
   525 				updateAtoolVersion(atooDirText.getText());
   525 				updateAtoolVersion(atoolDirText.getText());
   526 			}
   526 			}
   527 		} else if (event.widget == zeroButton || event.widget == fortyButton
   527 		} else if (event.widget == zeroButton || event.widget == fortyButton
   528 				|| event.widget == hundredButton) {
   528 				|| event.widget == hundredButton) {
   529 			spinner.setEnabled(false);
   529 			spinner.setEnabled(false);
   530 		} else if (event.widget == customButton) {
   530 		} else if (event.widget == customButton) {
   544 
   544 
   545 	/**
   545 	/**
   546 	 * Opens folder selection dialog.
   546 	 * Opens folder selection dialog.
   547 	 */
   547 	 */
   548 	public final void openFolderDialog() {
   548 	public final void openFolderDialog() {
   549 		DirectoryDialog folderDialog = new DirectoryDialog(atooDirText
   549 		DirectoryDialog folderDialog = new DirectoryDialog(atoolDirText
   550 				.getShell(), SWT.OPEN);
   550 				.getShell(), SWT.OPEN);
   551 		folderDialog.setText(Constants.PREFS_SELECT_DIR);
   551 		folderDialog.setText(Constants.PREFS_SELECT_DIR);
   552 		folderDialog.setFilterPath(atooDirText.getText());
   552 		folderDialog.setFilterPath(atoolDirText.getText());
   553 		String folderPath = folderDialog.open();
   553 		String folderPath = folderDialog.open();
   554 		if (folderPath != null) {
   554 		if (folderPath != null) {
   555 			atooDirText.setText(folderPath);
   555 			atoolDirText.setText(folderPath);
   556 		}
   556 		}
   557 	}
   557 	}
   558 
   558 
   559 	/**
   559 	/**
   560 	 * Perform defaults for AnalyzeTool preferences.
   560 	 * Perform defaults for AnalyzeTool preferences.
   566 
   566 
   567 			processButton.setSelection(true);
   567 			processButton.setSelection(true);
   568 			userButton.setSelection(false);
   568 			userButton.setSelection(false);
   569 			setGroupButtons(Constants.LOGGING_EXT);
   569 			setGroupButtons(Constants.LOGGING_EXT);
   570 
   570 
   571 			atooDirText.setText(Constants.DEFAULT_ATOOL_FOLDER);
   571 			atoolDirText.setText(Constants.DEFAULT_ATOOL_FOLDER);
   572 			useDefaultLocation.setSelection(true);
   572 			useDefaultLocation.setSelection(true);
   573 			handleDefaultLocationChange();
   573 			handleDefaultLocationChange();
   574 			verboseButton.setSelection(false);
   574 			verboseButton.setSelection(false);
   575 			zeroButton.setSelection(false);
   575 			zeroButton.setSelection(false);
   576 			fortyButton.setSelection(true);
   576 			fortyButton.setSelection(true);
   577 			hundredButton.setSelection(false);
   577 			hundredButton.setSelection(false);
   578 			customButton.setSelection(false);
   578 			customButton.setSelection(false);
   579 			spinner.setEnabled(false);
   579 			spinner.setEnabled(false);
       
   580 			
   580 			//generateStatistic.setSelection(false);
   581 			//generateStatistic.setSelection(false);
   581 			super.performDefaults();	
   582 			super.performDefaults();	
   582 		//}
   583 		//}
   583 	}
   584 	}
   584 
   585 
   590 	public final boolean performOk() {
   591 	public final boolean performOk() {
   591 		
   592 		
   592 		//check that AT prefs page is displayed
   593 		//check that AT prefs page is displayed
   593 		//if( getControl() != null && getControl().isVisible() ) {
   594 		//if( getControl() != null && getControl().isVisible() ) {
   594 			IPreferenceStore store = Activator.getPreferences();
   595 			IPreferenceStore store = Activator.getPreferences();
   595 			String atoolFolder = atooDirText.getText();
   596 			String atoolFolder = atoolDirText.getText();
   596 
   597 
   597 			// use default location is selected
   598 			// use default location is selected
   598 			if (useDefaultLocation.getSelection()) {
   599 			if (useDefaultLocation.getSelection()) {
   599 				store.setValue(Constants.ATOOL_FOLDER, Util
   600 				store.setValue(Constants.ATOOL_FOLDER, Util
   600 						.getDefaultAtoolLocation());
   601 						.getDefaultAtoolLocation());
   674 			}
   675 			}
   675 
   676 
   676 			// store callstack size
   677 			// store callstack size
   677 			store.setValue(Constants.USE_CALLSTACK_SIZE, userDefinedCSSize);
   678 			store.setValue(Constants.USE_CALLSTACK_SIZE, userDefinedCSSize);
   678 			store.setValue(Constants.CALLSTACK_SIZE, size);
   679 			store.setValue(Constants.CALLSTACK_SIZE, size);
   679 
   680 			
   680 			// update view with new settings
   681 			// update view with new settings
   681 			IActionListener listener = Activator.getActionListener();
   682 			IActionListener listener = Activator.getActionListener();
   682 			if (listener != null) {
   683 			if (listener != null) {
   683 				listener.preferenceChanged();
   684 				listener.preferenceChanged();
   684 			}
   685 			}