Added
Link Here
|
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2010 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.ui.internal.net; |
12 |
|
13 |
import java.util.Iterator; |
14 |
import java.util.List; |
15 |
|
16 |
import org.eclipse.core.runtime.IStatus; |
17 |
import org.eclipse.jface.dialogs.MessageDialog; |
18 |
import org.eclipse.jface.dialogs.StatusDialog; |
19 |
import org.eclipse.jface.viewers.ColumnWeightData; |
20 |
import org.eclipse.jface.viewers.TableLayout; |
21 |
import org.eclipse.swt.SWT; |
22 |
import org.eclipse.swt.custom.TableEditor; |
23 |
import org.eclipse.swt.events.SelectionAdapter; |
24 |
import org.eclipse.swt.events.SelectionEvent; |
25 |
import org.eclipse.swt.layout.FillLayout; |
26 |
import org.eclipse.swt.widgets.Button; |
27 |
import org.eclipse.swt.widgets.Composite; |
28 |
import org.eclipse.swt.widgets.Control; |
29 |
import org.eclipse.swt.widgets.Shell; |
30 |
import org.eclipse.swt.widgets.Table; |
31 |
import org.eclipse.swt.widgets.TableColumn; |
32 |
import org.eclipse.swt.widgets.TableItem; |
33 |
|
34 |
public class ProxyTestResultDialog extends StatusDialog { |
35 |
|
36 |
private List testResults; |
37 |
|
38 |
public ProxyTestResultDialog(Shell parent, List testResults) { |
39 |
super(parent); |
40 |
this.testResults = testResults; |
41 |
this.setTitle(NetUIMessages.ProxyTestDialog_0); |
42 |
this.setHelpAvailable(false); |
43 |
} |
44 |
|
45 |
|
46 |
protected Control createDialogArea(Composite parent) { |
47 |
Composite composite = new Composite(parent, SWT.NONE); |
48 |
FillLayout fillLayout = new FillLayout(); |
49 |
fillLayout.marginHeight = 10; |
50 |
fillLayout.marginWidth = 10; |
51 |
composite.setLayout(fillLayout); |
52 |
|
53 |
Table resultsTable = new Table(composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION); |
54 |
resultsTable.setHeaderVisible(true); |
55 |
resultsTable.setLinesVisible(true); |
56 |
|
57 |
TableLayout tableLayout = new TableLayout(); |
58 |
tableLayout.addColumnData(new ColumnWeightData(20, 120, true)); |
59 |
tableLayout.addColumnData(new ColumnWeightData(20, 150, true)); |
60 |
tableLayout.addColumnData(new ColumnWeightData(20, 150, true)); |
61 |
tableLayout.addColumnData(new ColumnWeightData(20, 50, true)); |
62 |
tableLayout.addColumnData(new ColumnWeightData(20, 50, true)); |
63 |
resultsTable.setLayout(tableLayout); |
64 |
|
65 |
TableColumn providerColumn = new TableColumn(resultsTable, SWT.NONE); |
66 |
providerColumn.setText(NetUIMessages.ProxyTestDialog_1); |
67 |
TableColumn descColumn = new TableColumn(resultsTable, SWT.NONE); |
68 |
descColumn.setText(NetUIMessages.ProxyTestDialog_2); |
69 |
TableColumn hostColumn = new TableColumn(resultsTable, SWT.NONE); |
70 |
hostColumn.setText(NetUIMessages.ProxyTestDialog_3); |
71 |
TableColumn resultColumn = new TableColumn(resultsTable, SWT.NONE); |
72 |
resultColumn.setText(NetUIMessages.ProxyTestDialog_4); |
73 |
TableColumn errorColumn = new TableColumn(resultsTable, SWT.NONE); |
74 |
errorColumn.setText(NetUIMessages.ProxyTestDialog_5); |
75 |
|
76 |
if (testResults != null) { |
77 |
Iterator it = testResults.iterator(); |
78 |
while(it.hasNext()) { |
79 |
final IStatus s = (IStatus) it.next(); |
80 |
TableItem item = new TableItem(resultsTable, SWT.NONE); |
81 |
item.setText(0, s.getPlugin()); |
82 |
item.setText(2, s.getMessage()); |
83 |
if (s.getSeverity() == IStatus.OK) { |
84 |
item.setText(3, NetUIMessages.ProxyTestDialog_6); |
85 |
} else { |
86 |
item.setText(3, NetUIMessages.ProxyTestDialog_7); |
87 |
} |
88 |
if (s.getException() != null) { |
89 |
TableEditor editor = new TableEditor(resultsTable); |
90 |
Button details = new Button(resultsTable, SWT.NONE); |
91 |
editor.grabHorizontal = true; |
92 |
details.setText(NetUIMessages.ProxyTestDialog_8); |
93 |
editor.setEditor(details, item, 4); |
94 |
details.addSelectionListener(new SelectionAdapter() { |
95 |
public void widgetSelected(SelectionEvent e) { |
96 |
MessageDialog.openInformation(getShell(), NetUIMessages.ProxyTestDialog_9, s.getException().getMessage()); |
97 |
} |
98 |
}); |
99 |
} |
100 |
} |
101 |
} |
102 |
resultsTable.pack(); |
103 |
return composite; |
104 |
} |
105 |
} |