remotecontrol/com.nokia.s60tools.remotecontrol/src/com/nokia/s60tools/remotecontrol/preferences/RCPreferencePage.java
author Maria Zhelezova <ext-maria.zhelezova@nokia.com>
Mon, 06 Sep 2010 08:39:29 +0300
changeset 17 aa3399e01058
parent 0 61163b28edca
permissions -rw-r--r--
RemoteControl 1.5.0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     1
/*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     2
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     3
* All rights reserved.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     4
* This component and the accompanying materials are made available
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     6
* which accompanies this distribution, and is available
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     8
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     9
* Initial Contributors:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    11
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    12
* Contributors:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    13
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    14
* Description:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    15
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    16
*/
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    17
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    18
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    19
package com.nokia.s60tools.remotecontrol.preferences;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    20
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    21
import org.eclipse.jface.preference.PreferencePage;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    22
import org.eclipse.swt.SWT;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    23
import org.eclipse.swt.layout.GridData;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    24
import org.eclipse.swt.layout.GridLayout;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    25
import org.eclipse.swt.widgets.Composite;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    26
import org.eclipse.swt.widgets.Control;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    27
import org.eclipse.swt.widgets.TabFolder;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    28
import org.eclipse.swt.widgets.TabItem;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    29
import org.eclipse.ui.IWorkbench;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    30
import org.eclipse.ui.IWorkbenchPreferencePage;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    31
import org.eclipse.ui.PlatformUI;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    32
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    33
import com.nokia.s60tools.remotecontrol.RemoteControlHelpContextIDs;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    34
import com.nokia.s60tools.remotecontrol.common.ProductInfoRegistry;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    35
import com.nokia.s60tools.remotecontrol.resources.Messages;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    36
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    37
/**
17
aa3399e01058 RemoteControl 1.5.0
Maria Zhelezova <ext-maria.zhelezova@nokia.com>
parents: 0
diff changeset
    38
 * Preference page for Remote control
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    39
 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    40
public class RCPreferencePage extends PreferencePage implements
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    41
		IWorkbenchPreferencePage {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    42
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    43
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    44
	 * ID for Remote Control preferences page.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    45
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    46
	public static final String PAGE_ID = "com.nokia.s60tools.remotecontrol.RCPreferencePage"; //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    47
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    48
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    49
	 * Enumeration of possible tabs in the page.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    50
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    51
	public enum Tabs {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    52
		SCREENCAPTURE,
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    53
		FTP
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    54
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    55
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    56
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    57
	 *  Screen capture preference UI
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    58
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    59
	private ScreenCapturePreferencesUI scPrefUI;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    60
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    61
	 *  Ftp preference UI
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    62
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    63
	private FtpPreferencesUI ftpPrefUI;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    64
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    65
	 * Folder containing tabs in the page.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    66
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    67
	private TabFolder tabFolder;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    68
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    69
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    70
	 * General constructor for opening default page.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    71
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    72
	public RCPreferencePage() {
17
aa3399e01058 RemoteControl 1.5.0
Maria Zhelezova <ext-maria.zhelezova@nokia.com>
parents: 0
diff changeset
    73
		super(ProductInfoRegistry.getProductName());
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    74
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    75
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    76
	/*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    77
	 * (non-Javadoc)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    78
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    79
	 * @see
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    80
	 * org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    81
	 * .swt.widgets.Composite)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    82
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    83
	protected Control createContents(Composite parent) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    84
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    85
		Composite container = new Composite(parent, SWT.SIMPLE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    86
		container.setLayout(new GridLayout(1, false));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    87
		container.setLayoutData(new GridData(GridData.FILL_BOTH));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    88
				
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    89
		// Create tab folder
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    90
		tabFolder = new TabFolder(container, SWT.TOP | SWT.FILL);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    91
		tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    92
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    93
		// Create tabs
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    94
		createScreenCaptureTab(tabFolder);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    95
		createFtpTab(tabFolder);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    96
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    97
		// Setting context help IDs	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    98
		PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    99
	    		RemoteControlHelpContextIDs.REMOTE_CONTROL_PREFERENCES);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   100
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   101
		return container;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   102
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   103
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   104
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   105
	 * Opens specified tab in preferences page.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   106
	 * @param tab to be opened.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   107
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   108
	public void openTab(Tabs tab) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   109
		// Opening correct tab.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   110
		if (tab == Tabs.SCREENCAPTURE) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   111
			tabFolder.setSelection(0);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   112
		} else if (tab == Tabs.FTP) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   113
			tabFolder.setSelection(1);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   114
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   115
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   116
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   117
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   118
	 * Creates Ftp tab
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   119
	 * @param tabFolder Tab folder where tab should be added
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   120
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   121
	private void createFtpTab(TabFolder tabFolder) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   122
		TabItem ftpTab = new TabItem(tabFolder, SWT.FILL);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   123
		ftpTab.setText(Messages.getString("RCPreferencePage.Ftp_Tabname")); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   124
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   125
		// Create tab content
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   126
		ftpPrefUI = new FtpPreferencesUI(tabFolder, SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   127
		ftpPrefUI.setLayout(new GridLayout(1, false));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   128
		ftpPrefUI.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   129
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   130
		ftpTab.setControl(ftpPrefUI);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   131
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   132
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   133
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   134
	 * Creates Screen Capture tab
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   135
	 * @param tabFolder Tab folder where tab should be added
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   136
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   137
	private void createScreenCaptureTab(TabFolder tabFolder) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   138
		TabItem screenCaptureTab = new TabItem(tabFolder, SWT.FILL);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   139
		screenCaptureTab.setText(Messages.getString("RCPreferencePage.Screencapture_Tabname")); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   140
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   141
		// Create screen capture tab content
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   142
		scPrefUI = new ScreenCapturePreferencesUI(tabFolder, SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   143
		scPrefUI.setLayout(new GridLayout(1, false));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   144
		scPrefUI.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   145
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   146
		screenCaptureTab.setControl(scPrefUI);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   147
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   148
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   149
	/*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   150
	 * (non-Javadoc)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   151
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   152
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   153
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   154
	protected void performDefaults() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   155
		// Set default values
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   156
		scPrefUI.setDefaults();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   157
		ftpPrefUI.setDefaults();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   158
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   159
		super.performDefaults();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   160
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   161
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   162
	/*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   163
	 * (non-Javadoc)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   164
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   165
	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   166
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   167
	public boolean performOk() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   168
		// Save preferences
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   169
		scPrefUI.savePrefStoreValues();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   170
		ftpPrefUI.savePrefStoreValues();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   171
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   172
		return super.performOk();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   173
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   174
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   175
	/*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   176
	 * (non-Javadoc)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   177
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   178
	 * @see
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   179
	 * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   180
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   181
	public void init(IWorkbench workbench) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   182
		// Not needed
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   183
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   184
}