KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > launchConfigurations > LaunchConfigurationsViewer


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui.launchConfigurations;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.debug.core.DebugPlugin;
15 import org.eclipse.debug.core.ILaunchConfigurationType;
16 import org.eclipse.debug.ui.DebugUITools;
17 import org.eclipse.debug.ui.ILaunchGroup;
18 import org.eclipse.jface.viewers.IStructuredContentProvider;
19 import org.eclipse.jface.viewers.TableViewer;
20 import org.eclipse.jface.viewers.Viewer;
21 import org.eclipse.jface.viewers.ViewerSorter;
22 import org.eclipse.swt.SWT;
23 import org.eclipse.swt.widgets.Composite;
24
25 /**
26  * A viewer that displays launch configurations of a specific type, filtered by
27  * workbench capabilities and PRIVATE attribute.
28  *
29  * @since 3.1
30  */

31 public class LaunchConfigurationsViewer extends TableViewer {
32     
33     class ContentProvider implements IStructuredContentProvider {
34
35         /* (non-Javadoc)
36          * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
37          */

38         public Object JavaDoc[] getElements(Object JavaDoc inputElement) {
39             if (inputElement instanceof ILaunchConfigurationType) {
40                 try {
41                     return DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations((ILaunchConfigurationType) inputElement);
42                 } catch (CoreException e) {
43                 }
44             }
45             return new Object JavaDoc[0];
46         }
47
48         /* (non-Javadoc)
49          * @see org.eclipse.jface.viewers.IContentProvider#dispose()
50          */

51         public void dispose() {
52         }
53
54         /* (non-Javadoc)
55          * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
56          */

57         public void inputChanged(Viewer viewer, Object JavaDoc oldInput, Object JavaDoc newInput) {
58         }
59         
60     }
61
62     /**
63      * Constructs a viewer to display launch configuration types
64      *
65      * @param parent composite this viewer is contained in
66      * @param launchGroup the launch group being displayed
67      */

68     public LaunchConfigurationsViewer(Composite parent, ILaunchGroup launchGroup) {
69         super(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
70         setContentProvider(new ContentProvider());
71         setLabelProvider(DebugUITools.newDebugModelPresentation());
72         setSorter(new ViewerSorter());
73         addFilter(new LaunchGroupFilter(launchGroup));
74     }
75
76 }
77
Popular Tags