author | dadubrow |
Wed, 20 Oct 2010 09:35:54 -0500 | |
changeset 2163 | f0a9f2d04d4a |
parent 1061 | ceac11190019 |
permissions | -rw-r--r-- |
956 | 1 |
/* |
2 |
* Copyright (c) 2010 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 |
||
18 |
package com.nokia.cdt.internal.debug.launch.newwizard; |
|
19 |
||
20 |
import java.text.MessageFormat; |
|
21 |
||
22 |
import org.eclipse.core.runtime.IStatus; |
|
23 |
import org.eclipse.core.runtime.Status; |
|
24 |
import org.eclipse.jface.dialogs.IDialogConstants; |
|
25 |
import org.eclipse.jface.dialogs.IMessageProvider; |
|
26 |
import org.eclipse.jface.dialogs.TitleAreaDialog; |
|
27 |
import org.eclipse.jface.layout.GridLayoutFactory; |
|
28 |
import org.eclipse.swt.SWT; |
|
29 |
import org.eclipse.swt.widgets.Button; |
|
30 |
import org.eclipse.swt.widgets.Composite; |
|
1061
ceac11190019
bug 10815 - connection dialog listen to service status change and update status
dadubrow
parents:
983
diff
changeset
|
31 |
import org.eclipse.swt.widgets.Display; |
956 | 32 |
import org.eclipse.swt.widgets.Shell; |
33 |
||
983
8b4ee73c530c
New launch wizard UI tweaks based on demo feedback
dadubrow
parents:
969
diff
changeset
|
34 |
import com.nokia.carbide.cpp.ui.CarbideUIPlugin; |
8b4ee73c530c
New launch wizard UI tweaks based on demo feedback
dadubrow
parents:
969
diff
changeset
|
35 |
import com.nokia.carbide.cpp.ui.ICarbideSharedImages; |
956 | 36 |
import com.nokia.cdt.internal.debug.launch.LaunchPlugin; |
37 |
import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils; |
|
38 |
||
39 |
/** |
|
40 |
* |
|
41 |
*/ |
|
42 |
public abstract class AbstractLaunchSettingsDialog extends TitleAreaDialog { |
|
43 |
||
969 | 44 |
protected final static String UID = ".uid"; //$NON-NLS-1$ |
956 | 45 |
|
2163 | 46 |
protected final IWizardData data; |
956 | 47 |
protected int INDENT; |
48 |
private String title; |
|
49 |
||
50 |
protected abstract void validate(); |
|
51 |
||
52 |
/** |
|
53 |
* @param parentShell |
|
54 |
* @param data |
|
55 |
*/ |
|
2163 | 56 |
public AbstractLaunchSettingsDialog(Shell parentShell, IWizardData data) { |
956 | 57 |
super(parentShell); |
58 |
setShellStyle(getShellStyle() | SWT.RESIZE); |
|
59 |
this.data = data; |
|
60 |
} |
|
61 |
/* (non-Javadoc) |
|
62 |
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) |
|
63 |
*/ |
|
64 |
@Override |
|
65 |
protected void configureShell(Shell newShell) { |
|
66 |
super.configureShell(newShell); |
|
969 | 67 |
newShell.setText(Messages.getString("AbstractLaunchSettingsDialog.Title")); //$NON-NLS-1$ |
983
8b4ee73c530c
New launch wizard UI tweaks based on demo feedback
dadubrow
parents:
969
diff
changeset
|
68 |
setTitleImage(CarbideUIPlugin.getSharedImages().getImage(ICarbideSharedImages.IMG_NEW_LAUNCH_CONFIG_WIZARD_BANNER)); |
956 | 69 |
} |
70 |
||
71 |
protected Composite initDialogArea(Composite parent, String title, String helpId) { |
|
72 |
Composite composite = (Composite) super.createDialogArea(parent); |
|
73 |
GridLayoutFactory.fillDefaults().margins(6, 6).applyTo(composite); |
|
74 |
||
75 |
INDENT = convertWidthInCharsToPixels(4); |
|
76 |
||
77 |
setTitle(title); |
|
78 |
||
79 |
this.title = title; |
|
80 |
||
81 |
WorkbenchUtils.setHelpContextId(composite, helpId); |
|
82 |
||
83 |
return composite; |
|
84 |
} |
|
85 |
||
86 |
protected int severityToMsgType(int severity) { |
|
87 |
switch (severity) { |
|
88 |
case IStatus.OK: |
|
89 |
case IStatus.CANCEL: |
|
90 |
default: |
|
91 |
break; |
|
92 |
case IStatus.INFO: |
|
93 |
return IMessageProvider.INFORMATION; |
|
94 |
case IStatus.ERROR: |
|
95 |
return IMessageProvider.ERROR; |
|
96 |
case IStatus.WARNING: |
|
97 |
return IMessageProvider.WARNING; |
|
98 |
} |
|
99 |
return IMessageProvider.NONE; |
|
100 |
} |
|
101 |
||
102 |
protected IStatus error(String msg, Object... args) { |
|
103 |
return new Status(IStatus.ERROR, LaunchPlugin.PLUGIN_ID, |
|
104 |
MessageFormat.format(msg, args)); |
|
105 |
} |
|
106 |
||
107 |
protected IStatus warning(String msg, Object... args) { |
|
108 |
return new Status(IStatus.WARNING, LaunchPlugin.PLUGIN_ID, |
|
109 |
MessageFormat.format(msg, args)); |
|
110 |
} |
|
111 |
||
112 |
private void setOkEnabled(boolean enabled) { |
|
113 |
Button okButton = getButton(IDialogConstants.OK_ID); |
|
114 |
if (okButton != null) |
|
115 |
okButton.setEnabled(enabled); |
|
116 |
} |
|
117 |
||
1061
ceac11190019
bug 10815 - connection dialog listen to service status change and update status
dadubrow
parents:
983
diff
changeset
|
118 |
protected void updateStatus(final IStatus status) { |
ceac11190019
bug 10815 - connection dialog listen to service status change and update status
dadubrow
parents:
983
diff
changeset
|
119 |
Display.getDefault().asyncExec(new Runnable() { |
ceac11190019
bug 10815 - connection dialog listen to service status change and update status
dadubrow
parents:
983
diff
changeset
|
120 |
public void run() { |
ceac11190019
bug 10815 - connection dialog listen to service status change and update status
dadubrow
parents:
983
diff
changeset
|
121 |
setTitle(title); |
956 | 122 |
|
1061
ceac11190019
bug 10815 - connection dialog listen to service status change and update status
dadubrow
parents:
983
diff
changeset
|
123 |
if (status.isOK()) { |
ceac11190019
bug 10815 - connection dialog listen to service status change and update status
dadubrow
parents:
983
diff
changeset
|
124 |
setMessage("", IMessageProvider.NONE); //$NON-NLS-1$ |
ceac11190019
bug 10815 - connection dialog listen to service status change and update status
dadubrow
parents:
983
diff
changeset
|
125 |
} else { |
ceac11190019
bug 10815 - connection dialog listen to service status change and update status
dadubrow
parents:
983
diff
changeset
|
126 |
setMessage(status.getMessage(), severityToMsgType(status.getSeverity())); |
ceac11190019
bug 10815 - connection dialog listen to service status change and update status
dadubrow
parents:
983
diff
changeset
|
127 |
} |
ceac11190019
bug 10815 - connection dialog listen to service status change and update status
dadubrow
parents:
983
diff
changeset
|
128 |
|
ceac11190019
bug 10815 - connection dialog listen to service status change and update status
dadubrow
parents:
983
diff
changeset
|
129 |
setOkEnabled(!status.matches(IStatus.ERROR)); |
ceac11190019
bug 10815 - connection dialog listen to service status change and update status
dadubrow
parents:
983
diff
changeset
|
130 |
} |
ceac11190019
bug 10815 - connection dialog listen to service status change and update status
dadubrow
parents:
983
diff
changeset
|
131 |
}); |
956 | 132 |
} |
133 |
||
134 |
} |