0
|
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 "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.s60tools.imaker.internal.dialogs;
|
|
18 |
|
|
19 |
import org.eclipse.jface.dialogs.IDialogConstants;
|
|
20 |
import org.eclipse.jface.dialogs.TitleAreaDialog;
|
|
21 |
import org.eclipse.jface.resource.ImageDescriptor;
|
|
22 |
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
|
23 |
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
|
24 |
import org.eclipse.swt.SWT;
|
|
25 |
import org.eclipse.swt.graphics.Image;
|
|
26 |
import org.eclipse.swt.graphics.Point;
|
|
27 |
import org.eclipse.swt.layout.GridData;
|
|
28 |
import org.eclipse.swt.layout.GridLayout;
|
|
29 |
import org.eclipse.swt.widgets.Button;
|
|
30 |
import org.eclipse.swt.widgets.Composite;
|
|
31 |
import org.eclipse.swt.widgets.Control;
|
|
32 |
import org.eclipse.swt.widgets.Shell;
|
|
33 |
|
|
34 |
import com.nokia.s60tools.imaker.IEnvironmentManager;
|
|
35 |
import com.nokia.s60tools.imaker.IMakerPlugin;
|
|
36 |
import com.nokia.s60tools.imaker.Messages;
|
|
37 |
import com.nokia.s60tools.imaker.internal.managers.ProjectManager;
|
|
38 |
import com.nokia.s60tools.imaker.internal.viewers.IMakerTabsViewer;
|
|
39 |
|
|
40 |
public class LaunchIMakerDialog extends TitleAreaDialog {
|
|
41 |
|
|
42 |
/** Keep track of the currently visible dialog instance */
|
|
43 |
private static LaunchIMakerDialog fgCurrentlyVisibleLaunchIMakerDialog;
|
|
44 |
|
|
45 |
/** Id for 'Launch' button.*/
|
|
46 |
protected static final int ID_LAUNCH_BUTTON = IDialogConstants.CLIENT_ID + 1;
|
|
47 |
|
|
48 |
/** Id for 'Close' button.*/
|
|
49 |
protected static final int ID_CLOSE_BUTTON = IDialogConstants.CLIENT_ID + 2;
|
|
50 |
|
|
51 |
/** Id for 'Cancel' button.*/
|
|
52 |
protected static final int ID_CANCEL_BUTTON = IDialogConstants.CLIENT_ID + 3;
|
|
53 |
|
|
54 |
/**
|
|
55 |
* Constant specifying how wide this dialog is allowed to get (as a percentage of
|
|
56 |
* total available screen width) as a result of tab labels in the edit area.
|
|
57 |
*/
|
|
58 |
protected static final float MAX_DIALOG_WIDTH_PERCENT = 0.75f;
|
|
59 |
|
|
60 |
/**
|
|
61 |
* Constant specifying how tall this dialog is allowed to get (as a percentage of
|
|
62 |
* total available screen height) as a result of preferred tab size.
|
|
63 |
*/
|
|
64 |
protected static final float MAX_DIALOG_HEIGHT_PERCENT = 0.60f;
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Size of this dialog if there is no preference specifying a size.
|
|
68 |
*/
|
|
69 |
protected static final Point DEFAULT_INITIAL_DIALOG_SIZE = new Point(540, 650); //(620, 690)
|
|
70 |
|
|
71 |
|
|
72 |
/**
|
|
73 |
* Returns the currently visible dialog
|
|
74 |
* @return the currently visible launch dialog
|
|
75 |
*/
|
|
76 |
public static LaunchIMakerDialog getCurrentlyVisibleLaunchConfigurationDialog() {
|
|
77 |
return fgCurrentlyVisibleLaunchIMakerDialog;
|
|
78 |
}
|
|
79 |
|
|
80 |
/**
|
|
81 |
* Sets which launch dialog is currently the visible one
|
|
82 |
* @param dialog the dialog to set as the visible one
|
|
83 |
*/
|
|
84 |
public static void setCurrentlyVisibleLaunchConfigurationDialog(LaunchIMakerDialog dialog) {
|
|
85 |
fgCurrentlyVisibleLaunchIMakerDialog = dialog;
|
|
86 |
}
|
|
87 |
|
|
88 |
/**
|
|
89 |
* widgets
|
|
90 |
*/
|
|
91 |
private IMakerTabsViewer fTabViewer;
|
|
92 |
private Image fBannerImage;
|
|
93 |
|
|
94 |
private Button runButton;
|
|
95 |
|
|
96 |
private IMakerTabsViewer imakerTabsViewer;
|
|
97 |
|
|
98 |
private ProjectManager projectManager;
|
|
99 |
|
|
100 |
private String filePath;
|
|
101 |
|
|
102 |
private IEnvironmentManager environmentManager;
|
|
103 |
|
|
104 |
public LaunchIMakerDialog(Shell parentShell, ProjectManager projectManager, IEnvironmentManager manager) {
|
|
105 |
super(parentShell);
|
|
106 |
this.projectManager = projectManager;
|
|
107 |
this.environmentManager = manager;
|
|
108 |
}
|
|
109 |
|
|
110 |
public ProjectManager getProjectManager() {
|
|
111 |
return projectManager;
|
|
112 |
}
|
|
113 |
|
|
114 |
@Override
|
|
115 |
protected void configureShell(Shell shell) {
|
|
116 |
super.configureShell(shell);
|
|
117 |
shell.setText(getShellTitle());
|
|
118 |
}
|
|
119 |
private String getShellTitle() {
|
|
120 |
return Messages.getString("Project.name");
|
|
121 |
}
|
|
122 |
|
|
123 |
@Override
|
|
124 |
protected Control createDialogArea(Composite parent) {
|
|
125 |
Composite dialogComp = (Composite)super.createDialogArea(parent);
|
|
126 |
setTitle(Messages.getString("LaunchImakerDialog.title"));
|
|
127 |
setMessage(Messages.getString("LaunchImakerDialog.message"));
|
|
128 |
setImage();
|
|
129 |
|
|
130 |
addContent(dialogComp);
|
|
131 |
return dialogComp;
|
|
132 |
}
|
|
133 |
|
|
134 |
public void initialize() {
|
|
135 |
getTabViewer().initialize();
|
|
136 |
}
|
|
137 |
/**
|
|
138 |
* Adds content to the dialog area
|
|
139 |
*
|
|
140 |
* @param dialogComp
|
|
141 |
*/
|
|
142 |
protected void addContent(Composite dialogComp) {
|
|
143 |
GridData gd;
|
|
144 |
Composite topComp = new Composite(dialogComp, SWT.NONE);
|
|
145 |
gd = new GridData(GridData.FILL_BOTH);
|
|
146 |
topComp.setLayoutData(gd);
|
|
147 |
GridLayout topLayout = new GridLayout(1, false);
|
|
148 |
topComp.setLayout(topLayout);
|
|
149 |
|
|
150 |
Composite editAreaComp = createPreferenceEditArea(topComp);
|
|
151 |
gd = new GridData(GridData.FILL_BOTH);
|
|
152 |
editAreaComp.setLayoutData(gd);
|
|
153 |
|
|
154 |
dialogComp.layout(true);
|
|
155 |
initialize();
|
|
156 |
applyDialogFont(dialogComp);
|
|
157 |
}
|
|
158 |
|
|
159 |
private void setImage() {
|
|
160 |
setTitleImage(getBannerImage());
|
|
161 |
}
|
|
162 |
|
|
163 |
private Image getBannerImage() {
|
|
164 |
if (fBannerImage == null) {
|
|
165 |
ImageDescriptor descriptor = IMakerPlugin.getImageDescriptor("icons/imaker_dialog.png");
|
|
166 |
if (descriptor != null) {
|
|
167 |
fBannerImage = descriptor.createImage();
|
|
168 |
}
|
|
169 |
}
|
|
170 |
return fBannerImage;
|
|
171 |
}
|
|
172 |
|
|
173 |
private Composite createPreferenceEditArea(Composite parent) {
|
|
174 |
imakerTabsViewer = new IMakerTabsViewer(parent,environmentManager, this);
|
|
175 |
setTabViewer(imakerTabsViewer);
|
|
176 |
getTabViewer().addSelectionChangedListener(new ISelectionChangedListener() {
|
|
177 |
public void selectionChanged(SelectionChangedEvent event) {
|
|
178 |
// handleTabSelectionChanged();
|
|
179 |
}
|
|
180 |
});
|
|
181 |
return (Composite)getTabViewer().getControl();
|
|
182 |
}
|
|
183 |
|
|
184 |
|
|
185 |
/**
|
|
186 |
* A launch configuration dialog overrides this method
|
|
187 |
* to create a custom set of buttons in the button bar.
|
|
188 |
* This dialog has 'Launch' and 'Cancel'
|
|
189 |
* buttons.
|
|
190 |
*
|
|
191 |
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
|
|
192 |
*/
|
|
193 |
protected void createButtonsForButtonBar(Composite parent) {
|
|
194 |
createButton(parent, IDialogConstants.OK_ID, Messages.getString("LaunchImakerDialog.run"), true);
|
|
195 |
createButton(parent, ID_CLOSE_BUTTON, Messages.getString("LaunchImakerDialog.close"), false);
|
|
196 |
}
|
|
197 |
|
|
198 |
public Button getRunButton() {
|
|
199 |
return runButton;
|
|
200 |
}
|
|
201 |
/**
|
|
202 |
* Handle the 'close' & 'launch' buttons here, all others are handled
|
|
203 |
* in <code>Dialog</code>
|
|
204 |
*
|
|
205 |
* @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
|
|
206 |
*/
|
|
207 |
protected void buttonPressed(int buttonId) {
|
|
208 |
if (buttonId == IDialogConstants.OK_ID) {
|
|
209 |
setFilePath(imakerTabsViewer.handleRunPressed());
|
|
210 |
okPressed();
|
|
211 |
} else if (buttonId == ID_CLOSE_BUTTON) {
|
|
212 |
cancelPressed();
|
|
213 |
} else {
|
|
214 |
super.buttonPressed(buttonId);
|
|
215 |
}
|
|
216 |
}
|
|
217 |
|
|
218 |
@Override
|
|
219 |
protected Point getInitialSize() {
|
|
220 |
return DEFAULT_INITIAL_DIALOG_SIZE;
|
|
221 |
}
|
|
222 |
|
11
|
223 |
@Override
|
|
224 |
protected boolean isResizable() {
|
|
225 |
return true;
|
|
226 |
}
|
|
227 |
|
|
228 |
|
0
|
229 |
/**
|
|
230 |
* Sets the viewer used to display the tabs for a launch configuration.
|
|
231 |
*
|
|
232 |
* @param viewer the new view to set
|
|
233 |
*/
|
|
234 |
protected void setTabViewer(IMakerTabsViewer viewer) {
|
|
235 |
fTabViewer = viewer;
|
|
236 |
}
|
|
237 |
|
|
238 |
/**
|
|
239 |
* Returns the viewer used to display the tabs for a launch configuration.
|
|
240 |
*
|
|
241 |
* @return LaunchConfigurationTabGroupViewer
|
|
242 |
*/
|
|
243 |
protected IMakerTabsViewer getTabViewer() {
|
|
244 |
return fTabViewer;
|
|
245 |
}
|
|
246 |
|
|
247 |
/**
|
|
248 |
* @param filePath the filePath to set
|
|
249 |
*/
|
|
250 |
public void setFilePath(String path) {
|
|
251 |
this.filePath = path;
|
|
252 |
}
|
|
253 |
|
|
254 |
/**
|
|
255 |
* @return the filePath
|
|
256 |
*/
|
|
257 |
public String getFilePath() {
|
|
258 |
return filePath;
|
|
259 |
}
|
|
260 |
|
|
261 |
|
|
262 |
}
|