8 * Contributors: |
8 * Contributors: |
9 * Nokia - Initial API and implementation |
9 * Nokia - Initial API and implementation |
10 *******************************************************************************/ |
10 *******************************************************************************/ |
11 package org.eclipse.cdt.debug.internal.ui.views.executables; |
11 package org.eclipse.cdt.debug.internal.ui.views.executables; |
12 |
12 |
|
13 import java.util.List; |
|
14 |
13 import org.eclipse.cdt.debug.core.executables.Executable; |
15 import org.eclipse.cdt.debug.core.executables.Executable; |
14 import org.eclipse.cdt.debug.core.executables.ExecutablesManager; |
16 import org.eclipse.cdt.debug.core.executables.ExecutablesManager; |
15 import org.eclipse.cdt.debug.core.executables.IExecutablesChangeEvent; |
|
16 import org.eclipse.cdt.debug.core.executables.IExecutablesChangeListener; |
17 import org.eclipse.cdt.debug.core.executables.IExecutablesChangeListener; |
17 import org.eclipse.core.runtime.IProgressMonitor; |
18 import org.eclipse.core.runtime.IProgressMonitor; |
18 import org.eclipse.core.runtime.IStatus; |
19 import org.eclipse.core.runtime.IStatus; |
19 import org.eclipse.core.runtime.Status; |
20 import org.eclipse.core.runtime.Status; |
20 import org.eclipse.jface.action.IMenuListener; |
21 import org.eclipse.jface.action.IMenuListener; |
164 }; |
165 }; |
165 } |
166 } |
166 return new ExecutablesViewerComparator(sortType, column_sort_order[sortType]); |
167 return new ExecutablesViewerComparator(sortType, column_sort_order[sortType]); |
167 } |
168 } |
168 |
169 |
169 /* |
170 @Override |
170 * (non-Javadoc) |
171 protected String getColumnOrderKey() { |
171 * |
172 return P_COLUMN_ORDER_KEY_EXE; |
172 * @see org.eclipse.cdt.debug.core.executables.IExecutablesChangeListener#executablesChanged(org.eclipse.cdt.debug.core.executables.IExecutablesChangeEvent) |
173 } |
173 */ |
174 |
174 public void executablesChanged(IExecutablesChangeEvent event) { |
175 @Override |
175 // Executables have changed so refresh the view. |
176 protected String getSortedColumnIndexKey() { |
176 final ExecutablesViewer viewer = this; |
177 return P_SORTED_COLUMN_INDEX_KEY_EXE; |
|
178 } |
|
179 |
|
180 @Override |
|
181 protected String getSortedColumnDirectionKey() { |
|
182 return P_COLUMN_SORT_DIRECTION_KEY_EXE; |
|
183 } |
|
184 |
|
185 @Override |
|
186 protected String getVisibleColumnsKey() { |
|
187 return P_VISIBLE_COLUMNS_KEY_EXE; |
|
188 } |
|
189 |
|
190 @Override |
|
191 protected String getDefaultVisibleColumnsValue() { |
|
192 // default visible columns |
|
193 return "1,1,1,0,0,0"; //$NON-NLS-1$ |
|
194 } |
|
195 |
|
196 public void executablesChanged(final List<Executable> executables) { |
|
197 // some executables have been updated. if one of them is currently |
|
198 // selected, we need to update the source file list |
177 UIJob refreshJob = new UIJob(Messages.ExecutablesViewer_RefreshExecutablesView) { |
199 UIJob refreshJob = new UIJob(Messages.ExecutablesViewer_RefreshExecutablesView) { |
178 |
200 |
179 @Override |
201 @Override |
180 public IStatus runInUIThread(IProgressMonitor monitor) { |
202 public IStatus runInUIThread(IProgressMonitor monitor) { |
181 // if the user has selected an executable, they expect its |
203 // if the user has selected an executable, they expect its |
182 // list of source files to be refreshed automatically |
204 // list of source files to be refreshed automatically |
183 if (viewer.getSelection() != null && |
205 if (getSelection() != null && |
184 viewer.getSelection() instanceof IStructuredSelection) { |
206 getSelection() instanceof IStructuredSelection) { |
185 IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); |
207 IStructuredSelection selection = (IStructuredSelection)getSelection(); |
186 |
208 |
187 Object firstElement = selection.getFirstElement(); |
209 Object firstElement = selection.getFirstElement(); |
188 if (firstElement instanceof Executable) { |
210 if (firstElement instanceof Executable) { |
189 Executable executable = (Executable) firstElement; |
211 Executable executable = (Executable) firstElement; |
190 executable.setRefreshSourceFiles(true); |
212 if (executables.contains(executable)) { |
191 viewer.setSelection(selection); |
213 executable.setRefreshSourceFiles(true); |
|
214 setSelection(selection); |
|
215 } |
192 } |
216 } |
193 } |
217 } |
194 viewer.refresh(null); |
|
195 viewer.packColumns(); |
|
196 return Status.OK_STATUS; |
218 return Status.OK_STATUS; |
197 } |
219 } |
198 }; |
220 }; |
199 refreshJob.schedule(); |
221 refreshJob.schedule(); |
200 } |
222 } |
201 |
223 |
202 @Override |
224 public void executablesListChanged() { |
203 protected String getColumnOrderKey() { |
225 // Executables list has changed so refresh the view. |
204 return P_COLUMN_ORDER_KEY_EXE; |
226 UIJob refreshJob = new UIJob(Messages.ExecutablesViewer_RefreshExecutablesView) { |
205 } |
227 |
206 |
228 @Override |
207 @Override |
229 public IStatus runInUIThread(IProgressMonitor monitor) { |
208 protected String getSortedColumnIndexKey() { |
230 refresh(null); |
209 return P_SORTED_COLUMN_INDEX_KEY_EXE; |
231 packColumns(); |
210 } |
232 return Status.OK_STATUS; |
211 |
233 } |
212 @Override |
234 }; |
213 protected String getSortedColumnDirectionKey() { |
235 refreshJob.schedule(); |
214 return P_COLUMN_SORT_DIRECTION_KEY_EXE; |
|
215 } |
|
216 |
|
217 @Override |
|
218 protected String getVisibleColumnsKey() { |
|
219 return P_VISIBLE_COLUMNS_KEY_EXE; |
|
220 } |
|
221 |
|
222 @Override |
|
223 protected String getDefaultVisibleColumnsValue() { |
|
224 // default visible columns |
|
225 return "1,1,1,0,0,0"; //$NON-NLS-1$ |
|
226 } |
236 } |
227 } |
237 } |