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-- |
0 | 1 |
/* |
2 |
* Copyright (c) 2008 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 "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 |
||
18 |
||
19 |
package com.nokia.s60tools.remotecontrol.preferences; |
|
20 |
||
21 |
import org.eclipse.jface.preference.PreferencePage; |
|
22 |
import org.eclipse.swt.SWT; |
|
23 |
import org.eclipse.swt.layout.GridData; |
|
24 |
import org.eclipse.swt.layout.GridLayout; |
|
25 |
import org.eclipse.swt.widgets.Composite; |
|
26 |
import org.eclipse.swt.widgets.Control; |
|
27 |
import org.eclipse.swt.widgets.TabFolder; |
|
28 |
import org.eclipse.swt.widgets.TabItem; |
|
29 |
import org.eclipse.ui.IWorkbench; |
|
30 |
import org.eclipse.ui.IWorkbenchPreferencePage; |
|
31 |
import org.eclipse.ui.PlatformUI; |
|
32 |
||
33 |
import com.nokia.s60tools.remotecontrol.RemoteControlHelpContextIDs; |
|
34 |
import com.nokia.s60tools.remotecontrol.common.ProductInfoRegistry; |
|
35 |
import com.nokia.s60tools.remotecontrol.resources.Messages; |
|
36 |
||
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 | 39 |
*/ |
40 |
public class RCPreferencePage extends PreferencePage implements |
|
41 |
IWorkbenchPreferencePage { |
|
42 |
||
43 |
/** |
|
44 |
* ID for Remote Control preferences page. |
|
45 |
*/ |
|
46 |
public static final String PAGE_ID = "com.nokia.s60tools.remotecontrol.RCPreferencePage"; //$NON-NLS-1$ |
|
47 |
||
48 |
/** |
|
49 |
* Enumeration of possible tabs in the page. |
|
50 |
*/ |
|
51 |
public enum Tabs { |
|
52 |
SCREENCAPTURE, |
|
53 |
FTP |
|
54 |
} |
|
55 |
||
56 |
/** |
|
57 |
* Screen capture preference UI |
|
58 |
*/ |
|
59 |
private ScreenCapturePreferencesUI scPrefUI; |
|
60 |
/** |
|
61 |
* Ftp preference UI |
|
62 |
*/ |
|
63 |
private FtpPreferencesUI ftpPrefUI; |
|
64 |
/** |
|
65 |
* Folder containing tabs in the page. |
|
66 |
*/ |
|
67 |
private TabFolder tabFolder; |
|
68 |
||
69 |
/** |
|
70 |
* General constructor for opening default page. |
|
71 |
*/ |
|
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 | 74 |
} |
75 |
||
76 |
/* |
|
77 |
* (non-Javadoc) |
|
78 |
* |
|
79 |
* @see |
|
80 |
* org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse |
|
81 |
* .swt.widgets.Composite) |
|
82 |
*/ |
|
83 |
protected Control createContents(Composite parent) { |
|
84 |
||
85 |
Composite container = new Composite(parent, SWT.SIMPLE); |
|
86 |
container.setLayout(new GridLayout(1, false)); |
|
87 |
container.setLayoutData(new GridData(GridData.FILL_BOTH)); |
|
88 |
||
89 |
// Create tab folder |
|
90 |
tabFolder = new TabFolder(container, SWT.TOP | SWT.FILL); |
|
91 |
tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH)); |
|
92 |
||
93 |
// Create tabs |
|
94 |
createScreenCaptureTab(tabFolder); |
|
95 |
createFtpTab(tabFolder); |
|
96 |
||
97 |
// Setting context help IDs |
|
98 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, |
|
99 |
RemoteControlHelpContextIDs.REMOTE_CONTROL_PREFERENCES); |
|
100 |
||
101 |
return container; |
|
102 |
} |
|
103 |
||
104 |
/** |
|
105 |
* Opens specified tab in preferences page. |
|
106 |
* @param tab to be opened. |
|
107 |
*/ |
|
108 |
public void openTab(Tabs tab) { |
|
109 |
// Opening correct tab. |
|
110 |
if (tab == Tabs.SCREENCAPTURE) { |
|
111 |
tabFolder.setSelection(0); |
|
112 |
} else if (tab == Tabs.FTP) { |
|
113 |
tabFolder.setSelection(1); |
|
114 |
} |
|
115 |
} |
|
116 |
||
117 |
/** |
|
118 |
* Creates Ftp tab |
|
119 |
* @param tabFolder Tab folder where tab should be added |
|
120 |
*/ |
|
121 |
private void createFtpTab(TabFolder tabFolder) { |
|
122 |
TabItem ftpTab = new TabItem(tabFolder, SWT.FILL); |
|
123 |
ftpTab.setText(Messages.getString("RCPreferencePage.Ftp_Tabname")); //$NON-NLS-1$ |
|
124 |
||
125 |
// Create tab content |
|
126 |
ftpPrefUI = new FtpPreferencesUI(tabFolder, SWT.NONE); |
|
127 |
ftpPrefUI.setLayout(new GridLayout(1, false)); |
|
128 |
ftpPrefUI.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
|
129 |
||
130 |
ftpTab.setControl(ftpPrefUI); |
|
131 |
} |
|
132 |
||
133 |
/** |
|
134 |
* Creates Screen Capture tab |
|
135 |
* @param tabFolder Tab folder where tab should be added |
|
136 |
*/ |
|
137 |
private void createScreenCaptureTab(TabFolder tabFolder) { |
|
138 |
TabItem screenCaptureTab = new TabItem(tabFolder, SWT.FILL); |
|
139 |
screenCaptureTab.setText(Messages.getString("RCPreferencePage.Screencapture_Tabname")); //$NON-NLS-1$ |
|
140 |
||
141 |
// Create screen capture tab content |
|
142 |
scPrefUI = new ScreenCapturePreferencesUI(tabFolder, SWT.NONE); |
|
143 |
scPrefUI.setLayout(new GridLayout(1, false)); |
|
144 |
scPrefUI.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
|
145 |
||
146 |
screenCaptureTab.setControl(scPrefUI); |
|
147 |
} |
|
148 |
||
149 |
/* |
|
150 |
* (non-Javadoc) |
|
151 |
* |
|
152 |
* @see org.eclipse.jface.preference.PreferencePage#performDefaults() |
|
153 |
*/ |
|
154 |
protected void performDefaults() { |
|
155 |
// Set default values |
|
156 |
scPrefUI.setDefaults(); |
|
157 |
ftpPrefUI.setDefaults(); |
|
158 |
||
159 |
super.performDefaults(); |
|
160 |
} |
|
161 |
||
162 |
/* |
|
163 |
* (non-Javadoc) |
|
164 |
* |
|
165 |
* @see org.eclipse.jface.preference.PreferencePage#performOk() |
|
166 |
*/ |
|
167 |
public boolean performOk() { |
|
168 |
// Save preferences |
|
169 |
scPrefUI.savePrefStoreValues(); |
|
170 |
ftpPrefUI.savePrefStoreValues(); |
|
171 |
||
172 |
return super.performOk(); |
|
173 |
} |
|
174 |
||
175 |
/* |
|
176 |
* (non-Javadoc) |
|
177 |
* |
|
178 |
* @see |
|
179 |
* org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) |
|
180 |
*/ |
|
181 |
public void init(IWorkbench workbench) { |
|
182 |
// Not needed |
|
183 |
} |
|
184 |
} |