1
|
/*******************************************************************************
|
2
|
* Copyright (c) 2006, 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
|
|
12
|
package org.eclipse.ui.internal.navigator.filters;
|
13
|
|
14
|
import java.util.HashSet;
|
15
|
import java.util.Set;
|
16
|
|
17
|
import org.eclipse.jface.viewers.CheckStateChangedEvent;
|
18
|
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
19
|
import org.eclipse.jface.viewers.ICheckStateListener;
|
20
|
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
21
|
import org.eclipse.swt.SWT;
|
22
|
import org.eclipse.swt.layout.GridData;
|
23
|
import org.eclipse.swt.layout.GridLayout;
|
24
|
import org.eclipse.swt.widgets.Composite;
|
25
|
import org.eclipse.swt.widgets.Label;
|
26
|
import org.eclipse.swt.widgets.Table;
|
27
|
import org.eclipse.ui.navigator.INavigatorContentService;
|
28
|
|
29
|
/**
|
30
|
* @since 3.2
|
31
|
*
|
32
|
*/
|
33
|
public class CustomizationTab extends Composite {
|
34
|
|
35
|
|
36
|
private final INavigatorContentService contentService;
|
37
|
|
38
|
private CheckboxTableViewer tableViewer;
|
39
|
private final Set checkedItems = new HashSet();
|
40
|
|
41
|
private ICheckStateListener checkListener = new ICheckStateListener() {
|
42
|
|
43
|
public void checkStateChanged(CheckStateChangedEvent event) {
|
44
|
if(event.getChecked())
|
45
|
checkedItems.add(event.getElement());
|
46
|
else
|
47
|
checkedItems.remove(event.getElement());
|
48
|
}
|
49
|
|
50
|
};
|
51
|
|
52
|
protected CustomizationTab(Composite parent,
|
53
|
INavigatorContentService aContentService) {
|
54
|
super(parent, SWT.RESIZE);
|
55
|
|
56
|
contentService = aContentService;
|
57
|
setFont(getParent().getFont());
|
58
|
setLayout(new GridLayout());
|
59
|
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
|
60
|
setData(data);
|
61
|
|
62
|
}
|
63
|
|
64
|
protected Table getTable() {
|
65
|
return tableViewer.getTable();
|
66
|
}
|
67
|
|
68
|
protected void addSelectionChangedListener(
|
69
|
ISelectionChangedListener selectionListener) {
|
70
|
if (tableViewer != null) {
|
71
|
tableViewer
|
72
|
.addSelectionChangedListener(selectionListener);
|
73
|
}
|
74
|
}
|
75
|
|
76
|
protected void createTable() {
|
77
|
|
78
|
tableViewer = CheckboxTableViewer.newCheckList(this,SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
|
79
|
tableViewer.addCheckStateListener(checkListener);
|
80
|
|
81
|
tableViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
82
|
tableViewer.getControl().setFont(getFont());
|
83
|
|
84
|
}
|
85
|
|
86
|
/* (non-Javadoc)
|
87
|
* @see org.eclipse.swt.widgets.Widget#dispose()
|
88
|
*/
|
89
|
public void dispose() {
|
90
|
tableViewer.removeCheckStateListener(checkListener);
|
91
|
super.dispose();
|
92
|
|
93
|
}
|
94
|
|
95
|
protected void createInstructionsLabel(String labelText) {
|
96
|
|
97
|
Label extensionsInstructionLabel = new Label(this, SWT.BOLD | SWT.WRAP);
|
98
|
|
99
|
GridData gridData = new GridData(GridData.FILL_HORIZONTAL
|
100
|
| GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL
|
101
|
| GridData.VERTICAL_ALIGN_FILL);
|
102
|
|
103
|
extensionsInstructionLabel.setLayoutData(gridData);
|
104
|
extensionsInstructionLabel.setFont(getFont());
|
105
|
extensionsInstructionLabel.setText(labelText);
|
106
|
}
|
107
|
|
108
|
|
109
|
protected final INavigatorContentService getContentService() {
|
110
|
return contentService;
|
111
|
}
|
112
|
|
113
|
protected final CheckboxTableViewer getTableViewer() {
|
114
|
return tableViewer;
|
115
|
}
|
116
|
|
117
|
protected Set getCheckedItems() {
|
118
|
return checkedItems;
|
119
|
}
|
120
|
|
121
|
}
|