KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > views > dependencies > DependenciesViewListPage


1 /*******************************************************************************
2  * Copyright (c) 2007 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.pde.internal.ui.views.dependencies;
12
13 import org.eclipse.jface.viewers.IContentProvider;
14 import org.eclipse.jface.viewers.StructuredViewer;
15 import org.eclipse.jface.viewers.TableViewer;
16 import org.eclipse.swt.SWT;
17 import org.eclipse.swt.events.DisposeEvent;
18 import org.eclipse.swt.events.DisposeListener;
19 import org.eclipse.swt.widgets.Composite;
20 import org.eclipse.swt.widgets.Table;
21
22 public class DependenciesViewListPage extends DependenciesViewPage {
23     
24     /**
25      *
26      */

27     public DependenciesViewListPage(DependenciesView view,
28             IContentProvider contentProvider) {
29         super(view, contentProvider);
30     }
31
32     /*
33      * (non-Javadoc)
34      *
35      * @see org.eclipse.pde.internal.ui.view.DependenciesViewPage#createViewer(org.eclipse.swt.widgets.Composite)
36      */

37     protected StructuredViewer createViewer(Composite parent) {
38         Table table = new Table(parent, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
39
40         fViewer = new TableViewer(table);
41         fViewer.setContentProvider(fContentProvider);
42         final DependenciesLabelProvider labelProvider = new DependenciesLabelProvider(
43                 false);
44         fViewer.setLabelProvider(labelProvider);
45         fViewer.getControl().addDisposeListener(new DisposeListener() {
46             public void widgetDisposed(DisposeEvent e) {
47                 labelProvider.dispose();
48             }
49         });
50
51         return fViewer;
52     }
53     
54     protected void handleShowOptional(boolean isChecked, boolean refreshIfNecessary) {
55         if (fContentProvider instanceof CalleesListContentProvider) {
56             ((CalleesListContentProvider)fContentProvider).setShowOptional(isChecked);
57             if (refreshIfNecessary)
58                 fViewer.refresh();
59         }
60     }
61     
62     protected boolean isShowingOptional() {
63         if (fContentProvider instanceof CalleesListContentProvider) {
64             return ((CalleesListContentProvider)fContentProvider).getShowOptional();
65         }
66         return true;
67     }
68 }
69
Popular Tags