Removed
Link Here
|
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2008 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.jdt.internal.ui.dialogs; |
12 |
|
13 |
import org.eclipse.swt.SWT; |
14 |
import org.eclipse.swt.layout.GridData; |
15 |
import org.eclipse.swt.widgets.Composite; |
16 |
import org.eclipse.swt.widgets.Control; |
17 |
import org.eclipse.swt.widgets.Label; |
18 |
import org.eclipse.swt.widgets.Shell; |
19 |
import org.eclipse.swt.widgets.Table; |
20 |
|
21 |
import org.eclipse.jface.dialogs.IDialogConstants; |
22 |
import org.eclipse.jface.viewers.ILabelProvider; |
23 |
import org.eclipse.jface.viewers.IStructuredContentProvider; |
24 |
import org.eclipse.jface.viewers.TableViewer; |
25 |
|
26 |
import org.eclipse.ui.dialogs.SelectionDialog; |
27 |
|
28 |
public class ListDialog extends SelectionDialog { |
29 |
|
30 |
private IStructuredContentProvider fContentProvider; |
31 |
private ILabelProvider fLabelProvider; |
32 |
private Object fInput; |
33 |
private TableViewer fTableViewer; |
34 |
private boolean fAddCancelButton; |
35 |
|
36 |
public ListDialog(Shell parent) { |
37 |
super(parent); |
38 |
fAddCancelButton= false; |
39 |
} |
40 |
|
41 |
public void setInput(Object input) { |
42 |
fInput= input; |
43 |
} |
44 |
|
45 |
public void setContentProvider(IStructuredContentProvider sp){ |
46 |
fContentProvider= sp; |
47 |
} |
48 |
|
49 |
public void setLabelProvider(ILabelProvider lp){ |
50 |
fLabelProvider= lp; |
51 |
} |
52 |
|
53 |
public void setAddCancelButton(boolean addCancelButton) { |
54 |
fAddCancelButton= addCancelButton; |
55 |
} |
56 |
|
57 |
public TableViewer getTableViewer(){ |
58 |
return fTableViewer; |
59 |
} |
60 |
|
61 |
public boolean hasFilters(){ |
62 |
return fTableViewer.getFilters() != null && fTableViewer.getFilters().length != 0; |
63 |
} |
64 |
|
65 |
protected Label createMessageArea(Composite composite) { |
66 |
Label label = new Label(composite,SWT.WRAP); |
67 |
label.setText(getMessage()); |
68 |
GridData gd= new GridData(GridData.FILL_BOTH); |
69 |
gd.widthHint= convertWidthInCharsToPixels(55); |
70 |
label.setLayoutData(gd); |
71 |
applyDialogFont(label); |
72 |
return label; |
73 |
} |
74 |
|
75 |
protected Control createDialogArea(Composite container) { |
76 |
Composite parent= (Composite) super.createDialogArea(container); |
77 |
createMessageArea(parent); |
78 |
fTableViewer= new TableViewer(parent, getTableStyle()); |
79 |
fTableViewer.setContentProvider(fContentProvider); |
80 |
Table table= fTableViewer.getTable(); |
81 |
fTableViewer.setLabelProvider(fLabelProvider); |
82 |
fTableViewer.setInput(fInput); |
83 |
GridData gd= new GridData(GridData.FILL_BOTH); |
84 |
gd.widthHint= convertWidthInCharsToPixels(55); |
85 |
gd.heightHint= convertHeightInCharsToPixels(15); |
86 |
table.setLayoutData(gd); |
87 |
applyDialogFont(parent); |
88 |
return parent; |
89 |
} |
90 |
|
91 |
protected void createButtonsForButtonBar(Composite parent) { |
92 |
if (! fAddCancelButton) |
93 |
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); |
94 |
else |
95 |
super.createButtonsForButtonBar(parent); |
96 |
} |
97 |
|
98 |
protected int getTableStyle() { |
99 |
return SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER; |
100 |
} |
101 |
} |
102 |
|