1fe3a566047f40b06c1d62cde2c6ceb16a053ae1
[phpeclipse.git] /
1 /**********************************************************************
2  * Copyright (c) 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  *    IBM - Initial API and implementation
10  **********************************************************************/
11 package net.sourceforge.phpdt.monitor.ui.internal.view;
12
13 import java.text.SimpleDateFormat;
14 import java.util.Iterator;
15 import java.util.List;
16
17 import net.sourceforge.phpdt.monitor.core.*;
18 import net.sourceforge.phpdt.monitor.ui.internal.*;
19
20 import org.eclipse.core.runtime.IConfigurationElement;
21 import org.eclipse.jface.action.Action;
22 import org.eclipse.jface.action.IAction;
23 import org.eclipse.jface.action.IMenuManager;
24 import org.eclipse.jface.action.IToolBarManager;
25 import org.eclipse.jface.viewers.ISelection;
26 import org.eclipse.jface.viewers.ISelectionChangedListener;
27 import org.eclipse.jface.viewers.IStructuredSelection;
28 import org.eclipse.jface.viewers.SelectionChangedEvent;
29 import org.eclipse.jface.viewers.StructuredSelection;
30 import org.eclipse.jface.viewers.TreeViewer;
31 import org.eclipse.jface.window.Window;
32 import org.eclipse.swt.SWT;
33
34 import org.eclipse.swt.custom.SashForm;
35 import org.eclipse.swt.events.ModifyEvent;
36 import org.eclipse.swt.events.ModifyListener;
37 import org.eclipse.swt.layout.GridData;
38 import org.eclipse.swt.layout.GridLayout;
39 import org.eclipse.swt.widgets.Combo;
40 import org.eclipse.swt.widgets.Composite;
41 import org.eclipse.swt.widgets.Display;
42 import org.eclipse.swt.widgets.Label;
43 import org.eclipse.swt.widgets.Tree;
44 import org.eclipse.ui.IViewPart;
45 import org.eclipse.ui.IWorkbench;
46 import org.eclipse.ui.IWorkbenchPage;
47 import org.eclipse.ui.IWorkbenchWindow;
48 import org.eclipse.ui.PlatformUI;
49 import org.eclipse.ui.help.WorkbenchHelp;
50 import org.eclipse.ui.part.ViewPart;
51 /**
52  * View of TCP/IP activity.
53  */
54 public class MonitorView extends ViewPart {
55         protected Tree tree;
56         protected TreeViewer treeViewer;
57         protected MonitorTreeContentProvider contentProvider;
58
59         protected IRequestListener listener;
60         protected IViewerManager vm;
61         protected List requestViewers;
62         protected List responseViewers;
63
64         protected static SimpleDateFormat format = new SimpleDateFormat(MonitorUIPlugin.getResource("%viewDateFormat"));
65         protected static final String VIEW_ID = "net.sourceforge.phpeclipse.monitor.core.view";
66         protected static final String DEFAULT_VIEWER = "net.sourceforge.phpeclipse.monitor.core.viewers.byteviewer";
67
68         protected IAction httpHeaderAction;
69         
70         protected static MonitorView view;
71
72         /**
73          * MonitorView constructor comment.
74          */
75         public MonitorView() {
76                 super();
77                 view = this;
78         }
79         
80         protected void addListener() {
81                 listener = new IRequestListener() {
82                         public void requestAdded(final IRequest rr) {
83                                 Display.getDefault().asyncExec(new Runnable() {
84                                         public void run() {
85                                                 Integer in = new Integer(rr.getLocalPort());
86                                                 treeViewer.add(MonitorTreeContentProvider.ROOT, in);
87                                                 treeViewer.add(in, rr);
88                                                 treeViewer.setSelection(new StructuredSelection(rr), true);
89                                         }
90                                 });
91                         }
92
93                         public void requestChanged(final IRequest rr) {
94                                 Display.getDefault().asyncExec(new Runnable() {
95                                         public void run() {
96                                                 IStructuredSelection sel = (IStructuredSelection) treeViewer.getSelection();
97                                                 
98                                                 treeViewer.refresh(rr);
99                                                 if (!sel.isEmpty())
100                                                         treeViewer.setSelection(sel);
101                                         }
102                                 });
103                         }
104
105                         public void requestRemoved(final IRequest rr) {
106                                 Display.getDefault().asyncExec(new Runnable() {
107                                         public void run() {
108                                                 treeViewer.remove(rr);
109                                         }
110                                 });
111                         }
112                 };
113         
114                 MonitorCore.addRequestListener(listener);
115         }
116
117         /**
118          * Clear the view.
119          */
120         protected void clear() {
121                 Display.getDefault().asyncExec(new Runnable() {
122                         public void run() {
123                                 treeViewer.setSelection(null);
124                                 treeViewer.setInput(MonitorTreeContentProvider.ROOT);
125                         }
126                 });
127         }
128         
129         protected void setSelection(IRequest request) {
130                 if (treeViewer != null)
131                         treeViewer.setSelection(new StructuredSelection(request));
132         }
133         
134
135         /**
136          * Returns the inner component in a desktop part.
137          */
138         public void createPartControl(Composite parent) {
139                 SashForm sashFparent = new SashForm(parent, SWT.VERTICAL);
140                 GridLayout layout = new GridLayout();
141                 layout.numColumns = 2;
142                 layout.horizontalSpacing = 4;
143                 layout.verticalSpacing = 4;
144                 sashFparent.setLayout(layout);
145                 sashFparent.setLayoutData(new GridData(GridData.FILL_BOTH));
146                 WorkbenchHelp.setHelp(sashFparent, ContextIds.VIEW);
147                 
148                 // create tree panel
149                 Composite treePanel = new Composite(sashFparent, SWT.NONE);
150                 layout = new GridLayout();
151                 layout.numColumns = 2;
152                 layout.marginHeight = 0;
153                 layout.marginWidth = 0;
154                 treePanel.setLayout(layout);
155                 GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
156                 data.heightHint = 110;
157                 data.horizontalSpan = 2;
158                 treePanel.setLayoutData(data);
159         
160                 tree = new Tree(treePanel, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE);
161                 data = new GridData(GridData.FILL_BOTH);
162                 //data.widthHint = 120;
163                 tree.setLayoutData(data);
164                 treeViewer = new TreeViewer(tree);
165                 contentProvider = new MonitorTreeContentProvider();
166                 treeViewer.setContentProvider(contentProvider);
167                 treeViewer.setInput(MonitorTreeContentProvider.ROOT);
168                 treeViewer.setLabelProvider(new TreeLabelProvider());
169                 WorkbenchHelp.setHelp(tree, ContextIds.VIEW_TREE);
170         
171                 Composite detailsPanel = new Composite(treePanel, SWT.NONE);
172                 layout = new GridLayout();
173                 layout.numColumns = 1;
174                 layout.marginHeight = 2;
175                 layout.marginWidth = 0;
176                 detailsPanel.setLayout(layout);
177                 data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
178                 data.widthHint = 200;
179                 detailsPanel.setLayoutData(data);
180
181                 final Label label = new Label(detailsPanel, SWT.NONE);
182                 label.setText(MonitorUIPlugin.getResource("%viewTime", ""));
183                 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
184
185                 final Label label2 = new Label(detailsPanel, SWT.NONE);
186                 label2.setText(MonitorUIPlugin.getResource("%viewResponseTime", ""));
187                 label2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
188
189                 final Label label3 = new Label(detailsPanel, SWT.NONE);
190                 label3.setText(MonitorUIPlugin.getResource("%viewType", ""));
191                 label3.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
192
193                 // create center and right panels
194                 SashForm sashFchild = new SashForm(sashFparent, SWT.NONE);
195                 layout = new GridLayout();
196                 layout.numColumns = 2;
197                 layout.horizontalSpacing = 2;
198                 layout.verticalSpacing = 4;
199                 sashFchild.setLayout(layout);
200                 sashFparent.setWeights(new int[] { 30, 70 });
201         
202                 // request panel
203                 Composite request = new Composite(sashFchild, SWT.NONE);
204                 layout = new GridLayout();
205                 layout.verticalSpacing = 3;
206                 layout.marginHeight = 2;
207                 layout.marginWidth = 0;
208                 request.setLayout(layout);
209                 request.setLayoutData(new GridData(GridData.FILL_BOTH));
210
211                 Composite requestHeader = new Composite(request, SWT.NONE);
212                 layout = new GridLayout();
213                 layout.verticalSpacing = 0;
214                 layout.numColumns = 2;
215                 layout.marginHeight = 0;
216                 layout.marginWidth = 2;
217                 data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
218                 data.heightHint = 30;
219                 requestHeader.setLayout(layout);
220                 requestHeader.setLayoutData(data);
221
222                 Composite requestHeaderLeft = new Composite(requestHeader, SWT.NONE);
223                 layout = new GridLayout();
224                 layout.verticalSpacing = 2;
225                 layout.marginHeight = 0;
226                 layout.marginWidth = 0;
227                 data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
228                 data.heightHint = 30;
229                 requestHeaderLeft.setLayout(layout);
230                 requestHeaderLeft.setLayoutData(data);
231
232                 Label empty1 = new Label(requestHeaderLeft, SWT.NONE);
233                 empty1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
234                 
235                 final Label requestLabel = new Label(requestHeaderLeft, SWT.NONE);
236                 requestLabel.setText(MonitorUIPlugin.getResource("%viewRequest", ""));
237                 requestLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_END));
238
239                 final Label requestSizeLabel = new Label(requestHeaderLeft, SWT.NONE);
240                 requestSizeLabel.setText(MonitorUIPlugin.getResource("%viewSize", ""));
241                 requestSizeLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_END));
242
243                 Composite requestHeaderRight = new Composite(requestHeader, SWT.NONE);
244                 layout = new GridLayout();
245                 layout.verticalSpacing = 0;
246                 layout.marginHeight = 0;
247                 layout.marginWidth = 0;
248                 data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.FILL_VERTICAL);
249                 data.heightHint = 30;
250                 requestHeaderRight.setLayout(layout);
251                 requestHeaderRight.setLayoutData(data);
252                 
253                 Label empty2 = new Label(requestHeaderRight, SWT.NONE);
254                 empty2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
255                 
256                 Combo requestViewerCombo = new Combo(requestHeaderRight, SWT.DROP_DOWN | SWT.READ_ONLY);        
257                 requestViewerCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_END));
258
259                 // response panel
260                 Composite response = new Composite(sashFchild, SWT.NONE);
261                 layout = new GridLayout();
262                 layout.verticalSpacing = 3;
263                 layout.marginHeight = 2;
264                 layout.marginWidth = 0;
265                 response.setLayout(layout);
266                 response.setLayoutData(new GridData(GridData.FILL_BOTH));
267
268                 Composite responseHeader = new Composite(response, SWT.NONE);
269                 layout = new GridLayout();
270                 layout.verticalSpacing = 0;
271                 layout.numColumns = 2;
272                 layout.marginHeight = 0;
273                 layout.marginWidth = 2;
274                 data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
275                 data.heightHint = 30;
276                 responseHeader.setLayout(layout);
277                 responseHeader.setLayoutData(data);
278
279                 Composite responseHeaderLeft = new Composite(responseHeader, SWT.NONE);
280                 layout = new GridLayout();
281                 layout.verticalSpacing = 2;
282                 layout.marginHeight = 0;
283                 layout.marginWidth = 0;
284                 data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
285                 data.heightHint = 30;
286                 responseHeaderLeft.setLayout(layout);
287                 responseHeaderLeft.setLayoutData(data);
288
289                 Label empty3 = new Label(responseHeaderLeft, SWT.NONE);
290                 empty3.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
291         
292                 final Label responseLabel = new Label(responseHeaderLeft, SWT.NONE);
293                 responseLabel.setText(MonitorUIPlugin.getResource("%viewResponse", ""));
294                 responseLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
295         
296                 final Label responseSizeLabel = new Label(responseHeaderLeft, SWT.NONE);
297                 responseSizeLabel.setText(MonitorUIPlugin.getResource("%viewSize", ""));
298                 responseSizeLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_END));
299
300                 Composite responseHeaderRight = new Composite(responseHeader, SWT.NONE);
301                 layout = new GridLayout();
302                 layout.verticalSpacing = 0;
303                 layout.marginHeight = 0;
304                 layout.marginWidth = 0;
305                 data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.FILL_VERTICAL);
306                 data.heightHint = 30;
307                 responseHeaderRight.setLayout(layout);
308                 responseHeaderRight.setLayoutData(data);
309                 
310                 Label empty4 = new Label(responseHeaderRight, SWT.NONE);
311                 empty4.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
312                 
313                 Combo responseViewerCombo = new Combo(responseHeaderRight, SWT.DROP_DOWN | SWT.READ_ONLY);      
314                 responseViewerCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_END));
315         
316                 //Viewer manager
317                 vm = new ViewerManager(request, request, response, response);
318                 requestViewers = vm.getRequestViewers();
319                 responseViewers = vm.getResponseViewers();
320
321                 //Set up the viewer combo boxes
322                 Iterator iterator = requestViewers.iterator();
323                 int ctr = 0;
324                 while(iterator.hasNext()) {
325                         IConfigurationElement element = (IConfigurationElement) iterator.next();
326                         requestViewerCombo.add(element.getAttribute("label"), ctr);
327                         if (element.getAttribute("id").equals(DEFAULT_VIEWER)) {
328                                 requestViewerCombo.select(ctr); 
329                                 vm.setRequestViewer(element);
330                         }  
331                         ctr++;  
332                 }
333                 requestViewerCombo.addModifyListener(new ModifyListener() {
334                         public void modifyText(ModifyEvent arg0) {
335                                 Combo rvCombo = (Combo) arg0.getSource();
336                                 vm.setRequestViewer((IConfigurationElement) requestViewers.get(rvCombo.getSelectionIndex()));
337                         }
338                 });
339                 requestHeader.layout(true);
340                 
341                 iterator = responseViewers.iterator();
342                 ctr = 0;
343                 while(iterator.hasNext()) {
344                         IConfigurationElement element = (IConfigurationElement) iterator.next();
345                         responseViewerCombo.add(element.getAttribute("label"), ctr);
346                         if(element.getAttribute("id").equals(DEFAULT_VIEWER)) {
347                                 responseViewerCombo.select(ctr); 
348                                 vm.setResponseViewer(element);
349                         } 
350                         ctr++;
351                 }
352                 responseViewerCombo.addModifyListener(new ModifyListener() {
353                         public void modifyText(ModifyEvent arg0) {
354                                 Combo rvCombo = (Combo) arg0.getSource();
355                                 vm.setResponseViewer((IConfigurationElement) requestViewers.get(rvCombo.getSelectionIndex()));
356                         }
357                 });
358                 responseHeader.layout(true);
359
360                 // selection listener
361                 treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
362                         public void selectionChanged(SelectionChangedEvent event) {
363                                 ISelection selection = event.getSelection();
364
365                                 IRequest req = null;
366                                 if (selection != null && !selection.isEmpty()) {
367                                         StructuredSelection sel = (StructuredSelection) selection;
368                                         Object obj = sel.iterator().next();
369                                         if (obj instanceof IRequest)
370                                                 req = (IRequest) obj;
371                                 }
372         
373                                 if (req != null) {
374                                         label.setText(MonitorUIPlugin.getResource("%viewTime", format.format(req.getDate())));
375         
376                                         if (req.getResponseTime() == -1)
377                                                 label2.setText(MonitorUIPlugin.getResource("%viewResponseTime", ""));
378                                         else {
379                                                 String time = MonitorUIPlugin.getResource("%viewResponseTimeFormat", req.getResponseTime() + "");
380                                                 label2.setText(MonitorUIPlugin.getResource("%viewResponseTime", time));
381                                         }
382                                         label3.setText(MonitorUIPlugin.getResource("%viewType", req.getType().getName()));
383         
384                                         // request information
385                                         requestLabel.setText(MonitorUIPlugin.getResource("%viewRequest", "localhost:" + req.getLocalPort()));
386                                         requestSizeLabel.setText(getSizeString(req.getRequest(IRequest.CONTENT), req.getRequest(IRequest.ALL)));
387         
388                                         // response information
389                                         responseLabel.setText(MonitorUIPlugin.getResource("%viewResponse", req.getRemoteHost() + ":" + req.getRemotePort()));
390                                         responseSizeLabel.setText(getSizeString(req.getResponse(IRequest.CONTENT), req.getResponse(IRequest.ALL)));
391
392                                         vm.setRequest(req);
393                                 } else {
394                                         label.setText(MonitorUIPlugin.getResource("%viewTime", ""));
395                                         label2.setText(MonitorUIPlugin.getResource("%viewResponseTime", ""));
396                                         requestLabel.setText(MonitorUIPlugin.getResource("%viewRequest", ""));
397                                         requestSizeLabel.setText(MonitorUIPlugin.getResource("%viewSize", ""));
398                                         responseLabel.setText(MonitorUIPlugin.getResource("%viewResponse", ""));
399                                         responseSizeLabel.setText(MonitorUIPlugin.getResource("%viewSize", ""));
400                                         vm.setRequest(req);
401                                 }
402                         }
403                 });
404                 
405                 treeViewer.expandToLevel(2);
406         
407                 initializeActions();
408         
409                 addListener();
410         }
411         
412         protected String getSizeString(byte[] a, byte[] b) {
413                 String aa = "0";
414                 String bb = "0";
415                 if (a != null)
416                         aa = a.length + "";
417                 if (b != null)
418                         bb = b.length + "";
419                 String size = MonitorUIPlugin.getResource("%viewSizeFormat", new Object[] { aa, bb});
420                 return MonitorUIPlugin.getResource("%viewSize", size);
421         }
422
423         public void dispose() {
424                 super.dispose();
425                 treeViewer = null;
426                 MonitorCore.removeRequestListener(listener);
427         }
428
429         /**
430          * 
431          */
432         public void initializeActions() {
433                 final IAction sortByResponseTimeAction = new Action() {
434                         public void run() {
435                                 Display.getDefault().asyncExec(new Runnable() {
436                                         public void run() {
437                                                 boolean b = contentProvider.getSortByResponseTime();
438                                                 contentProvider.setSortByResponseTime(!b);
439                                                 treeViewer.refresh();
440                                                 setChecked(!b);
441                                         }
442                                 });
443                         }
444                 };
445                 sortByResponseTimeAction.setChecked(false);
446                 sortByResponseTimeAction.setToolTipText(MonitorUIPlugin.getResource("%actionSortByResponseTime"));
447                 sortByResponseTimeAction.setImageDescriptor(MonitorUIPlugin.getImageDescriptor(MonitorUIPlugin.IMG_ELCL_SORT_RESPONSE_TIME));
448                 sortByResponseTimeAction.setHoverImageDescriptor(MonitorUIPlugin.getImageDescriptor(MonitorUIPlugin.IMG_CLCL_SORT_RESPONSE_TIME));
449                 sortByResponseTimeAction.setDisabledImageDescriptor(MonitorUIPlugin.getImageDescriptor(MonitorUIPlugin.IMG_DLCL_SORT_RESPONSE_TIME));
450         
451                 IAction clearAction = new Action() {
452                         public void run() {
453                                 MonitorCore.removeAllRequests();
454                         }
455                 };
456                 clearAction.setToolTipText(MonitorUIPlugin.getResource("%actionClearToolTip"));
457                 clearAction.setImageDescriptor(MonitorUIPlugin.getImageDescriptor(MonitorUIPlugin.IMG_ELCL_CLEAR));
458                 clearAction.setHoverImageDescriptor(MonitorUIPlugin.getImageDescriptor(MonitorUIPlugin.IMG_CLCL_CLEAR));
459                 clearAction.setDisabledImageDescriptor(MonitorUIPlugin.getImageDescriptor(MonitorUIPlugin.IMG_DLCL_CLEAR));
460
461                 httpHeaderAction = new Action() {
462                         public void run() {
463                                 Display.getDefault().asyncExec(new Runnable() {
464                                         public void run() {
465                                                 boolean b = vm.getDisplayHeaderInfo();
466                                                 vm.setDisplayHeaderInfo(!b);
467                                                 setChecked(!b);
468                                         }
469                                 });
470                         }
471                 };
472                 httpHeaderAction.setChecked(vm.getDisplayHeaderInfo());
473                 httpHeaderAction.setText(MonitorUIPlugin.getResource("%actionShowHeader"));
474
475                 IAction preferenceAction = new Action() {
476                         public void run() {
477                                 IWorkbench workbench = PlatformUI.getWorkbench();
478                                 IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
479                                                                 
480                                 MonitorPrefrencesDialog monitorPrefDialog = new MonitorPrefrencesDialog(workbenchWindow.getShell());
481                                 if (monitorPrefDialog.open() == Window.CANCEL)
482                                         return;
483                         }
484                 };
485                 preferenceAction.setText(MonitorUIPlugin.getResource("%actionProperties"));
486                 
487                 
488                 IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager();
489                 tbm.add(sortByResponseTimeAction);
490                 tbm.add(clearAction);
491                 
492                 IContentFilter[] filters = MonitorCore.getContentFilters();
493                 IMenuManager menuManager = getViewSite().getActionBars().getMenuManager();
494                 menuManager.add(httpHeaderAction);
495                 int size = filters.length;
496                 for (int i = 0; i < size; i++) {
497                         FilterAction action = new FilterAction(vm, filters[i]);
498                         menuManager.add(action);
499                 }
500                 menuManager.add(preferenceAction);
501         }
502
503         /**
504          * 
505          */
506         public static void open(final IRequest request) {
507                 Display.getDefault().asyncExec(new Runnable() {
508                         public void run() {
509                                 try {
510                                         IWorkbench workbench = MonitorUIPlugin.getInstance().getWorkbench();
511                                         IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
512                                         //if (workbenchWindow == null)
513                                         //      workbenchWindow = workbench.getWorkbenchWindows()[0];
514         
515                                         IWorkbenchPage page = workbenchWindow.getActivePage();
516         
517                                         IViewPart view2 = page.findView(VIEW_ID);
518                                         
519                                         if (view2 != null)
520                                                 page.bringToTop(view2);
521                                         else
522                                                 page.showView(VIEW_ID);
523
524                                         if (view != null)
525                                                 view.setSelection(request);
526                                 } catch (Exception e) {
527                                         Trace.trace(Trace.SEVERE, "Error opening TCP/IP view", e);
528                                 }
529                         }
530                 });
531         }
532
533         /**
534          * 
535          */
536         public void setFocus() {
537                 if (tree != null)
538                         tree.setFocus();
539         }
540 }