Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2008 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2009 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 14-50
Link Here
|
14 |
import java.util.ArrayList; |
14 |
import java.util.ArrayList; |
15 |
import java.util.Iterator; |
15 |
import java.util.Iterator; |
16 |
|
16 |
|
17 |
import org.eclipse.jface.dialogs.Dialog; |
|
|
18 |
import org.eclipse.jface.dialogs.IDialogConstants; |
19 |
import org.eclipse.jface.dialogs.IDialogSettings; |
20 |
import org.eclipse.jface.dialogs.PopupDialog; |
21 |
import org.eclipse.jface.viewers.DoubleClickEvent; |
22 |
import org.eclipse.jface.viewers.IDoubleClickListener; |
23 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
24 |
import org.eclipse.jface.viewers.IStructuredSelection; |
25 |
import org.eclipse.jface.viewers.ITreeContentProvider; |
26 |
import org.eclipse.jface.viewers.ITreeSelection; |
27 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
28 |
import org.eclipse.jface.viewers.StructuredSelection; |
29 |
import org.eclipse.jface.viewers.TreeViewer; |
30 |
import org.eclipse.swt.SWT; |
17 |
import org.eclipse.swt.SWT; |
31 |
import org.eclipse.swt.events.DisposeEvent; |
18 |
import org.eclipse.swt.events.DisposeEvent; |
32 |
import org.eclipse.swt.events.DisposeListener; |
19 |
import org.eclipse.swt.events.DisposeListener; |
33 |
import org.eclipse.swt.events.FocusAdapter; |
|
|
34 |
import org.eclipse.swt.events.FocusEvent; |
35 |
import org.eclipse.swt.events.KeyAdapter; |
36 |
import org.eclipse.swt.events.KeyEvent; |
37 |
import org.eclipse.swt.graphics.Color; |
20 |
import org.eclipse.swt.graphics.Color; |
38 |
import org.eclipse.swt.graphics.Point; |
|
|
39 |
import org.eclipse.swt.graphics.RGB; |
21 |
import org.eclipse.swt.graphics.RGB; |
40 |
import org.eclipse.swt.layout.GridData; |
22 |
import org.eclipse.swt.layout.GridData; |
41 |
import org.eclipse.swt.widgets.Button; |
23 |
import org.eclipse.swt.widgets.Button; |
42 |
import org.eclipse.swt.widgets.Composite; |
24 |
import org.eclipse.swt.widgets.Composite; |
43 |
import org.eclipse.swt.widgets.Control; |
25 |
import org.eclipse.swt.widgets.Control; |
44 |
import org.eclipse.swt.widgets.Display; |
|
|
45 |
import org.eclipse.swt.widgets.Label; |
46 |
import org.eclipse.swt.widgets.Shell; |
26 |
import org.eclipse.swt.widgets.Shell; |
47 |
import org.eclipse.swt.widgets.Text; |
27 |
import org.eclipse.swt.widgets.Text; |
|
|
28 |
|
29 |
import org.eclipse.jface.dialogs.Dialog; |
30 |
import org.eclipse.jface.dialogs.IDialogConstants; |
31 |
import org.eclipse.jface.dialogs.IDialogSettings; |
32 |
import org.eclipse.jface.viewers.DoubleClickEvent; |
33 |
import org.eclipse.jface.viewers.IDoubleClickListener; |
34 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
35 |
import org.eclipse.jface.viewers.IStructuredSelection; |
36 |
import org.eclipse.jface.viewers.ITreeContentProvider; |
37 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
38 |
import org.eclipse.jface.viewers.StructuredSelection; |
39 |
import org.eclipse.jface.viewers.TreeViewer; |
40 |
|
48 |
import org.eclipse.ui.IWorkbenchWindow; |
41 |
import org.eclipse.ui.IWorkbenchWindow; |
49 |
import org.eclipse.ui.PlatformUI; |
42 |
import org.eclipse.ui.PlatformUI; |
50 |
import org.eclipse.ui.dialogs.FilteredTree; |
43 |
import org.eclipse.ui.dialogs.FilteredTree; |
Lines 163-173
Link Here
|
163 |
|
156 |
|
164 |
layoutTopControl(filteredTree); |
157 |
layoutTopControl(filteredTree); |
165 |
|
158 |
|
166 |
// Use F2... label |
|
|
167 |
Label label = new Label(composite, SWT.WRAP); |
168 |
label.setText(WorkbenchMessages.ShowView_selectViewHelp); |
169 |
label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
170 |
|
171 |
// Restore the last state |
159 |
// Restore the last state |
172 |
restoreWidgetValues(); |
160 |
restoreWidgetValues(); |
173 |
|
161 |
|
Lines 231-241
Link Here
|
231 |
treeViewer.addSelectionChangedListener(this); |
219 |
treeViewer.addSelectionChangedListener(this); |
232 |
treeViewer.addDoubleClickListener(this); |
220 |
treeViewer.addDoubleClickListener(this); |
233 |
treeViewer.addFilter(new CapabilityFilter()); |
221 |
treeViewer.addFilter(new CapabilityFilter()); |
234 |
treeViewer.getControl().addKeyListener(new KeyAdapter() { |
|
|
235 |
public void keyPressed(KeyEvent e) { |
236 |
handleTreeViewerKeyPressed(e); |
237 |
} |
238 |
}); |
239 |
|
222 |
|
240 |
// if the tree has only one or zero views, disable the filter text control |
223 |
// if the tree has only one or zero views, disable the filter text control |
241 |
if (hasAtMostOneView(filteredTree.getViewer())) { |
224 |
if (hasAtMostOneView(filteredTree.getViewer())) { |
Lines 424-479
Link Here
|
424 |
protected IDialogSettings getDialogBoundsSettings() { |
407 |
protected IDialogSettings getDialogBoundsSettings() { |
425 |
return getDialogSettings(); |
408 |
return getDialogSettings(); |
426 |
} |
409 |
} |
427 |
void handleTreeViewerKeyPressed(KeyEvent event) { |
|
|
428 |
// popup the description for the selected view |
429 |
if (event.keyCode == SWT.F2 && event.stateMask == 0) { |
430 |
ITreeSelection selection = (ITreeSelection) filteredTree |
431 |
.getViewer().getSelection(); |
432 |
// only show description if one view is selected |
433 |
if (selection.size() == 1) { |
434 |
Object o = selection.getFirstElement(); |
435 |
if (o instanceof IViewDescriptor) { |
436 |
String description = ((IViewDescriptor) o).getDescription(); |
437 |
if (description.length() == 0) |
438 |
description = WorkbenchMessages.ShowView_noDesc; |
439 |
popUp(description); |
440 |
} |
441 |
} |
442 |
} |
443 |
} |
444 |
|
410 |
|
445 |
private void popUp(final String description) { |
|
|
446 |
new PopupDialog(filteredTree.getShell(), PopupDialog.HOVER_SHELLSTYLE, |
447 |
true, false, false, false, false, null, null) { |
448 |
private static final int CURSOR_SIZE = 15; |
449 |
|
450 |
protected Point getInitialLocation(Point initialSize) { |
451 |
//show popup relative to cursor |
452 |
Display display = getShell().getDisplay(); |
453 |
Point location = display.getCursorLocation(); |
454 |
location.x += CURSOR_SIZE; |
455 |
location.y += CURSOR_SIZE; |
456 |
return location; |
457 |
} |
458 |
|
459 |
protected Control createDialogArea(Composite parent) { |
460 |
Label label = new Label(parent, SWT.WRAP); |
461 |
label.setText(description); |
462 |
label.addFocusListener(new FocusAdapter() { |
463 |
public void focusLost(FocusEvent event) { |
464 |
close(); |
465 |
} |
466 |
}); |
467 |
// Use the compact margins employed by PopupDialog. |
468 |
GridData gd = new GridData(GridData.BEGINNING |
469 |
| GridData.FILL_BOTH); |
470 |
gd.horizontalIndent = PopupDialog.POPUP_HORIZONTALSPACING; |
471 |
gd.verticalIndent = PopupDialog.POPUP_VERTICALSPACING; |
472 |
label.setLayoutData(gd); |
473 |
return label; |
474 |
} |
475 |
}.open(); |
476 |
} |
477 |
/* |
411 |
/* |
478 |
* (non-Javadoc) |
412 |
* (non-Javadoc) |
479 |
* @see org.eclipse.jface.dialogs.Dialog#isResizable() |
413 |
* @see org.eclipse.jface.dialogs.Dialog#isResizable() |