1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/*******************************************************************************
* Copyright (c) 2004, 2008 Tasktop Technologies and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tasktop Technologies - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.internal.tasks.ui.dialogs;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.PopupDialog;
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
/**
* @author Mik Kersten
* @author Leo Dos Santos
*/
public class UiLegendDialog extends PopupDialog {
private FormToolkit toolkit;
private ScrolledForm form;
private UiLegendControl content;
public UiLegendDialog(Shell parent) {
super(parent, PopupDialog.INFOPOPUP_SHELLSTYLE | SWT.ON_TOP, false, false, false, false, false, null, null);
}
@Override
protected Control createContents(Composite parent) {
getShell().setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
return createDialogArea(parent);
}
@Override
public int open() {
int open = super.open();
// getShell().setLocation(getShell().getLocation().x, getShell().getLocation().y+20);
getShell().setFocus();
return open;
}
@Override
public boolean close() {
if (form != null && !form.isDisposed()) {
form.dispose();
}
if (toolkit != null) {
if (toolkit.getColors() != null) {
toolkit.dispose();
}
}
if (content != null && !content.isDisposed()) {
content.dispose();
}
return super.close();
}
@Override
protected Control createDialogArea(Composite parent) {
toolkit = new FormToolkit(parent.getDisplay());
form = toolkit.createScrolledForm(parent);
form.setText(Messages.UiLegendControl_Tasks_UI_Legend);
form.getToolBarManager().add(new CloseDialogAction());
form.getToolBarManager().update(true);
form.getBody().setLayout(new TableWrapLayout());
toolkit.decorateFormHeading(form.getForm());
content = new UiLegendControl(form.getBody(), toolkit);
content.setWindow(this);
return parent;
}
private class CloseDialogAction extends Action {
private CloseDialogAction() {
setImageDescriptor(CommonImages.NOTIFICATION_CLOSE);
setText(Messages.UiLegendDialog_Close_Dialog);
}
@Override
public void run() {
close();
}
}
}
|