core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/AddSBSv2ProductVariant.java
equal
deleted
inserted
replaced
25 import org.eclipse.jface.dialogs.IDialogConstants; |
25 import org.eclipse.jface.dialogs.IDialogConstants; |
26 import org.eclipse.jface.dialogs.MessageDialog; |
26 import org.eclipse.jface.dialogs.MessageDialog; |
27 import org.eclipse.jface.dialogs.TrayDialog; |
27 import org.eclipse.jface.dialogs.TrayDialog; |
28 import org.eclipse.swt.SWT; |
28 import org.eclipse.swt.SWT; |
29 import org.eclipse.swt.custom.CCombo; |
29 import org.eclipse.swt.custom.CCombo; |
|
30 import org.eclipse.swt.events.KeyEvent; |
|
31 import org.eclipse.swt.events.KeyListener; |
|
32 import org.eclipse.swt.events.SelectionEvent; |
|
33 import org.eclipse.swt.events.SelectionListener; |
30 import org.eclipse.swt.graphics.Point; |
34 import org.eclipse.swt.graphics.Point; |
31 import org.eclipse.swt.layout.GridData; |
35 import org.eclipse.swt.layout.GridData; |
32 import org.eclipse.swt.layout.GridLayout; |
36 import org.eclipse.swt.layout.GridLayout; |
33 import org.eclipse.swt.widgets.Composite; |
37 import org.eclipse.swt.widgets.Composite; |
34 import org.eclipse.swt.widgets.Control; |
38 import org.eclipse.swt.widgets.Control; |
61 for (String alias : aliasMap.keySet()){ |
65 for (String alias : aliasMap.keySet()){ |
62 aliasList.add(alias); |
66 aliasList.add(alias); |
63 } |
67 } |
64 variantList = productVariantList; |
68 variantList = productVariantList; |
65 defaultAlias = selectedAlias; |
69 defaultAlias = selectedAlias; |
66 |
|
67 |
|
68 } |
70 } |
69 |
71 |
70 /** |
72 /** |
71 * Create contents of the button bar |
73 * Create contents of the button bar |
72 * @param parent |
74 * @param parent |
75 protected void createButtonsForButtonBar(Composite parent) { |
77 protected void createButtonsForButtonBar(Composite parent) { |
76 createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, |
78 createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, |
77 true); |
79 true); |
78 createButton(parent, IDialogConstants.CANCEL_ID, |
80 createButton(parent, IDialogConstants.CANCEL_ID, |
79 IDialogConstants.CANCEL_LABEL, false); |
81 IDialogConstants.CANCEL_LABEL, false); |
|
82 |
|
83 getButton(IDialogConstants.OK_ID).setEnabled(false); |
80 } |
84 } |
81 |
85 |
82 /** |
86 /** |
83 * Create contents of the dialog |
87 * Create contents of the dialog |
84 * @param parent |
88 * @param parent |
98 aliasCombo = new CCombo(container, SWT.BORDER); |
102 aliasCombo = new CCombo(container, SWT.BORDER); |
99 aliasCombo.setLayoutData(new GridData(263, SWT.DEFAULT)); |
103 aliasCombo.setLayoutData(new GridData(263, SWT.DEFAULT)); |
100 Collections.sort(aliasList); |
104 Collections.sort(aliasList); |
101 aliasCombo.setItems((String[])aliasList.toArray(new String[aliasList.size()])); |
105 aliasCombo.setItems((String[])aliasList.toArray(new String[aliasList.size()])); |
102 aliasCombo.select(0); |
106 aliasCombo.select(0); |
|
107 aliasCombo.setEditable(false); |
|
108 aliasCombo.addSelectionListener(new SelectionListener() { |
|
109 public void widgetSelected(SelectionEvent e) { |
|
110 validateData(); |
|
111 } |
|
112 public void widgetDefaultSelected(SelectionEvent e) { |
|
113 // ignore |
|
114 } |
|
115 }); |
|
116 aliasCombo.addKeyListener(new KeyListener() { |
|
117 public void keyReleased(KeyEvent e) { |
|
118 validateData(); |
|
119 } |
|
120 public void keyPressed(KeyEvent e) { |
|
121 |
|
122 } |
|
123 }); |
|
124 |
103 |
125 |
104 if (defaultAlias != null && defaultAlias.length() > 0) |
126 if (defaultAlias != null && defaultAlias.length() > 0) |
105 aliasCombo.setText(defaultAlias); |
127 aliasCombo.setText(defaultAlias); |
106 |
128 |
107 new Label(container, SWT.NONE); |
129 new Label(container, SWT.NONE); |
112 |
134 |
113 variantCombo = new CCombo(container, SWT.BORDER); |
135 variantCombo = new CCombo(container, SWT.BORDER); |
114 variantCombo.setLayoutData(new GridData(263, SWT.DEFAULT)); |
136 variantCombo.setLayoutData(new GridData(263, SWT.DEFAULT)); |
115 Collections.sort(variantList); |
137 Collections.sort(variantList); |
116 variantCombo.setItems((String[])variantList.toArray(new String[variantList.size()])); |
138 variantCombo.setItems((String[])variantList.toArray(new String[variantList.size()])); |
117 |
139 variantCombo.addSelectionListener(new SelectionListener() { |
|
140 public void widgetSelected(SelectionEvent e) { |
|
141 validateData(); |
|
142 } |
|
143 public void widgetDefaultSelected(SelectionEvent e) { |
|
144 // ignore |
|
145 } |
|
146 }); |
|
147 variantCombo.addKeyListener(new KeyListener() { |
|
148 public void keyReleased(KeyEvent e) { |
|
149 validateData(); |
|
150 } |
|
151 public void keyPressed(KeyEvent e) { |
|
152 |
|
153 } |
|
154 }); |
|
155 |
|
156 |
118 PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, SDKUIHelpIds.SDK_ADD_DIALOG); |
157 PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, SDKUIHelpIds.SDK_ADD_DIALOG); |
119 return container; |
158 return container; |
120 } |
159 } |
121 |
160 |
122 /* (non-Javadoc) |
161 /* (non-Javadoc) |
163 } |
202 } |
164 |
203 |
165 public String getUserCreatedVariant() { |
204 public String getUserCreatedVariant() { |
166 return newConfigString; |
205 return newConfigString; |
167 } |
206 } |
|
207 |
|
208 private void validateData(){ |
|
209 if (variantCombo.getText().length() > 0){ |
|
210 getButton(IDialogConstants.OK_ID).setEnabled(true); |
|
211 } else { |
|
212 getButton(IDialogConstants.OK_ID).setEnabled(false); |
|
213 return; |
|
214 } |
|
215 |
|
216 if (aliasCombo.getText().length() > 0){ |
|
217 getButton(IDialogConstants.OK_ID).setEnabled(true); |
|
218 } else { |
|
219 getButton(IDialogConstants.OK_ID).setEnabled(false); |
|
220 return; |
|
221 } |
|
222 } |
168 |
223 |
169 } |
224 } |