Lines 10-26
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.team.internal.ccvs.ui.repo; |
11 |
package org.eclipse.team.internal.ccvs.ui.repo; |
12 |
|
12 |
|
13 |
import java.util.Arrays; |
13 |
import java.util.HashSet; |
|
|
14 |
import java.util.Set; |
14 |
|
15 |
|
15 |
import org.eclipse.core.runtime.IAdaptable; |
16 |
import org.eclipse.core.runtime.IAdaptable; |
|
|
17 |
import org.eclipse.jface.dialogs.*; |
16 |
import org.eclipse.jface.dialogs.Dialog; |
18 |
import org.eclipse.jface.dialogs.Dialog; |
17 |
import org.eclipse.jface.dialogs.IDialogSettings; |
|
|
18 |
import org.eclipse.jface.resource.ImageDescriptor; |
19 |
import org.eclipse.jface.resource.ImageDescriptor; |
19 |
import org.eclipse.jface.util.IPropertyChangeListener; |
20 |
import org.eclipse.jface.util.IPropertyChangeListener; |
20 |
import org.eclipse.jface.util.PropertyChangeEvent; |
21 |
import org.eclipse.jface.util.PropertyChangeEvent; |
21 |
import org.eclipse.swt.SWT; |
22 |
import org.eclipse.swt.SWT; |
|
|
23 |
import org.eclipse.swt.events.*; |
24 |
import org.eclipse.swt.graphics.FontMetrics; |
25 |
import org.eclipse.swt.graphics.GC; |
26 |
import org.eclipse.swt.layout.GridData; |
22 |
import org.eclipse.swt.layout.GridLayout; |
27 |
import org.eclipse.swt.layout.GridLayout; |
23 |
import org.eclipse.swt.widgets.Composite; |
28 |
import org.eclipse.swt.widgets.*; |
24 |
import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; |
29 |
import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; |
25 |
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; |
30 |
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; |
26 |
import org.eclipse.team.internal.ccvs.ui.*; |
31 |
import org.eclipse.team.internal.ccvs.ui.*; |
Lines 28-33
Link Here
|
28 |
import org.eclipse.team.internal.ccvs.ui.wizards.CVSWizardPage; |
33 |
import org.eclipse.team.internal.ccvs.ui.wizards.CVSWizardPage; |
29 |
import org.eclipse.ui.IWorkingSet; |
34 |
import org.eclipse.ui.IWorkingSet; |
30 |
import org.eclipse.ui.PlatformUI; |
35 |
import org.eclipse.ui.PlatformUI; |
|
|
36 |
import org.eclipse.ui.dialogs.FilteredTree; |
37 |
import org.eclipse.ui.dialogs.PatternFilter; |
31 |
import org.eclipse.ui.model.IWorkbenchAdapter; |
38 |
import org.eclipse.ui.model.IWorkbenchAdapter; |
32 |
import org.eclipse.ui.model.WorkbenchLabelProvider; |
39 |
import org.eclipse.ui.model.WorkbenchLabelProvider; |
33 |
|
40 |
|
Lines 42-47
Link Here
|
42 |
private WorkingSetSelectionArea workingSetArea; |
49 |
private WorkingSetSelectionArea workingSetArea; |
43 |
private IWorkingSet workingSet; |
50 |
private IWorkingSet workingSet; |
44 |
private IDialogSettings settings; |
51 |
private IDialogSettings settings; |
|
|
52 |
private FilteredTree ft; |
53 |
private final Set remotes = new HashSet(); |
54 |
private FontMetrics fontMetrics; |
45 |
|
55 |
|
46 |
/** |
56 |
/** |
47 |
* Custom input provider which returns the list of root folders |
57 |
* Custom input provider which returns the list of root folders |
Lines 83-94
Link Here
|
83 |
super(pageName, title, titleImage, description); |
93 |
super(pageName, title, titleImage, description); |
84 |
this.settings = settings; |
94 |
this.settings = settings; |
85 |
this.rootFolders = rootFolders; |
95 |
this.rootFolders = rootFolders; |
|
|
96 |
|
86 |
} |
97 |
} |
87 |
|
98 |
|
88 |
/** |
99 |
/** |
89 |
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) |
100 |
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) |
90 |
*/ |
101 |
*/ |
91 |
public void createControl(Composite parent) { |
102 |
public void createControl(Composite parent) { |
|
|
103 |
GC gc = new GC(parent); |
104 |
gc.setFont(parent.getFont()); |
105 |
fontMetrics = gc.getFontMetrics(); |
106 |
gc.dispose(); |
92 |
|
107 |
|
93 |
final Composite composite = new Composite(parent, SWT.NONE); |
108 |
final Composite composite = new Composite(parent, SWT.NONE); |
94 |
composite.setLayout(new GridLayout(1, false)); |
109 |
composite.setLayout(new GridLayout(1, false)); |
Lines 98-116
Link Here
|
98 |
// set F1 help |
113 |
// set F1 help |
99 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.REFRESH_REMOTE_PROJECT_SELECTION_PAGE); |
114 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.REFRESH_REMOTE_PROJECT_SELECTION_PAGE); |
100 |
|
115 |
|
101 |
listArea = new ListSelectionArea( |
116 |
Label label = new Label(composite, SWT.LEFT | SWT.WRAP); |
102 |
new InputElement(), |
117 |
label.setText(CVSUIMessages.RefreshRemoteProjectSelectionPage_selectRemoteProjects); |
103 |
new RemoteContentProvider(), |
118 |
label.setFont(parent.getFont()); |
104 |
new WorkbenchLabelProvider(), |
119 |
GridData data = new GridData(); |
105 |
CVSUIMessages.RefreshRemoteProjectSelectionPage_selectRemoteProjects); |
120 |
data.horizontalAlignment = GridData.FILL; |
106 |
listArea.createArea(composite); |
121 |
data.grabExcessHorizontalSpace = true; |
|
|
122 |
data.widthHint= 0; |
123 |
label.setLayoutData(data); |
124 |
|
125 |
ft = new FilteredTree(composite, SWT.CHECK | SWT.BORDER, new PatternFilter()); |
126 |
GridData fdata = new GridData(SWT.FILL, SWT.FILL, true, true); |
127 |
fdata.heightHint = 0; // It will expand to the size of the wizard page! |
128 |
fdata.widthHint = 0; |
129 |
ft.getViewer().getTree().setLayoutData(fdata); |
130 |
|
131 |
|
132 |
final InputElement ie = new InputElement(); |
133 |
ft.getViewer().setLabelProvider(new WorkbenchLabelProvider()); |
134 |
ft.getViewer().setContentProvider(new RemoteContentProvider(){ |
107 |
|
135 |
|
108 |
listArea.addPropertyChangeListener(new IPropertyChangeListener() { |
136 |
public Object[] getChildren(Object element) { |
109 |
public void propertyChange(PropertyChangeEvent event) { |
137 |
if(element == ie){ |
110 |
updateEnablement(); |
138 |
return super.getChildren(element); |
|
|
139 |
} |
140 |
return new Object[]{}; |
111 |
} |
141 |
} |
112 |
}); |
142 |
|
113 |
listArea.getViewer().setComparator(new RepositoryComparator()); |
143 |
public boolean hasChildren(Object element) { |
|
|
144 |
if(element == ie){ |
145 |
return super.hasChildren(element); |
146 |
} |
147 |
return false; |
148 |
} |
149 |
|
150 |
}); |
151 |
ft.getViewer().setInput(ie); |
152 |
ft.getViewer().setComparator(new RepositoryComparator()); |
153 |
ft.getViewer().getTree().addSelectionListener(new SelectionListener(){ |
154 |
|
155 |
public void widgetDefaultSelected(SelectionEvent e) {} |
156 |
|
157 |
public void widgetSelected(SelectionEvent e) { |
158 |
if(e.detail == SWT.CHECK){ |
159 |
TreeItem data = (TreeItem) e.item; |
160 |
if(data.getChecked()){ |
161 |
remotes.add(data.getData()); |
162 |
} else { |
163 |
remotes.remove(data.getData()); |
164 |
} |
165 |
updateEnablement(); |
166 |
} |
167 |
} |
168 |
|
169 |
}); |
170 |
|
171 |
ft.getFilterControl().addModifyListener(new ModifyListener(){ |
172 |
|
173 |
public void modifyText(ModifyEvent e) { |
174 |
TreeItem[] items = ft.getViewer().getTree().getItems(); |
175 |
for(int i = 0; i < items.length; i++){ |
176 |
if(remotes.contains(items[i].getData())){ |
177 |
items[i].setChecked(true); |
178 |
} else { |
179 |
items[i].setChecked(false); |
180 |
} |
181 |
} |
182 |
} |
183 |
|
184 |
}); |
185 |
|
186 |
|
187 |
Composite buttonComposite = new Composite(composite, SWT.RIGHT); |
188 |
buttonComposite.setLayout(new GridLayout(2, false)); |
189 |
buttonComposite.setData(new GridData(SWT.END, SWT.BEGINNING, true, false)); |
190 |
|
191 |
Button selectButton = createButton(buttonComposite, CVSUIMessages.ListSelectionArea_selectAll, GridData.HORIZONTAL_ALIGN_FILL); |
192 |
|
193 |
SelectionListener listener = new SelectionAdapter() { |
194 |
public void widgetSelected(SelectionEvent e) { |
195 |
TreeItem[] items = ft.getViewer().getTree().getItems(); |
196 |
for(int i = 0; i < items.length; i++){ |
197 |
items[i].setChecked(true); |
198 |
remotes.add(items[i].getData()); |
199 |
} |
200 |
} |
201 |
}; |
202 |
selectButton.addSelectionListener(listener); |
203 |
|
204 |
|
205 |
Button deselectButton = createButton(buttonComposite, CVSUIMessages.ListSelectionArea_deselectAll, GridData.HORIZONTAL_ALIGN_FILL); |
206 |
|
207 |
listener = new SelectionAdapter() { |
208 |
public void widgetSelected(SelectionEvent e) { |
209 |
TreeItem[] items = ft.getViewer().getTree().getItems(); |
210 |
for(int i = 0; i < items.length; i++){ |
211 |
items[i].setChecked(false); |
212 |
remotes.remove(items[i].getData()); |
213 |
} |
214 |
} |
215 |
}; |
216 |
deselectButton.addSelectionListener(listener); |
114 |
|
217 |
|
115 |
workingSetArea = new WorkingSetSelectionArea(getShell(), CVSUIMessages.RefreshRemoteProjectSelectionPage_noWorkingSet, CVSUIMessages.RefreshRemoteProjectSelectionPage_workingSet, settings); // |
218 |
workingSetArea = new WorkingSetSelectionArea(getShell(), CVSUIMessages.RefreshRemoteProjectSelectionPage_noWorkingSet, CVSUIMessages.RefreshRemoteProjectSelectionPage_workingSet, settings); // |
116 |
setWorkingSet(workingSet); |
219 |
setWorkingSet(workingSet); |
Lines 123-129
Link Here
|
123 |
workingSetArea.createArea(composite); |
226 |
workingSetArea.createArea(composite); |
124 |
Dialog.applyDialogFont(parent); |
227 |
Dialog.applyDialogFont(parent); |
125 |
} |
228 |
} |
|
|
229 |
|
230 |
protected Button createButton(Composite parent, String label, int style) { |
231 |
Button button = new Button(parent, SWT.PUSH); |
232 |
button.setText(label); |
233 |
// we need to explicitly set the font to the parent's font for dialogs |
234 |
button.setFont(parent.getFont()); |
235 |
GridData data = new GridData(style); |
236 |
data.heightHint = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_HEIGHT); |
237 |
int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); |
238 |
data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); |
239 |
button.setLayoutData(data); |
240 |
return button; |
241 |
} |
126 |
|
242 |
|
|
|
243 |
|
127 |
/** |
244 |
/** |
128 |
* Sets the working set that should be selected in the most recently |
245 |
* Sets the working set that should be selected in the most recently |
129 |
* used working set list. |
246 |
* used working set list. |
Lines 155-162
Link Here
|
155 |
} |
272 |
} |
156 |
|
273 |
|
157 |
private void updateEnablement() { |
274 |
private void updateEnablement() { |
158 |
boolean atLeastOne = listArea.getViewer().getCheckedElements().length > 0; |
275 |
setPageComplete(remotes.size() > 0); |
159 |
setPageComplete(atLeastOne); |
|
|
160 |
} |
276 |
} |
161 |
|
277 |
|
162 |
/** |
278 |
/** |
Lines 164-170
Link Here
|
164 |
* @return ICVSRemoteResource[] |
280 |
* @return ICVSRemoteResource[] |
165 |
*/ |
281 |
*/ |
166 |
public ICVSRemoteResource[] getSelectedRemoteProject() { |
282 |
public ICVSRemoteResource[] getSelectedRemoteProject() { |
167 |
Object[] checked = listArea.getViewer().getCheckedElements(); |
283 |
return (ICVSRemoteResource[]) remotes.toArray(new ICVSRemoteResource[]{}); |
168 |
return (ICVSRemoteResource[]) Arrays.asList(checked).toArray(new ICVSRemoteResource[checked.length]); |
|
|
169 |
} |
284 |
} |
170 |
} |
285 |
} |