147
|
1 module user.PopUp;
|
|
2 import tango.util.log.Trace;
|
|
3
|
|
4 import dwt.dwthelper.utils;
|
|
5 import dwt.DWT;
|
|
6
|
|
7 import dwt.layout.GridLayout;
|
|
8 import dwt.layout.GridData;
|
149
|
9 import dwt.layout.FillLayout;
|
147
|
10
|
|
11 import dwt.graphics.Image;
|
|
12
|
|
13 import dwt.widgets.Text;
|
|
14 import dwt.widgets.Control;
|
|
15 import dwt.widgets.Composite;
|
|
16 import dwt.widgets.Group;
|
|
17 import dwt.widgets.Display;
|
|
18 import dwt.widgets.Shell;
|
|
19 import dwt.widgets.Listener;
|
|
20 import dwt.widgets.Event;
|
|
21 import dwt.widgets.Button;
|
149
|
22 import dwt.widgets.Label;
|
147
|
23
|
|
24 import dwtx.jface.dialogs.PopupDialog;
|
149
|
25 import dwtx.jface.dialogs.ErrorDialog;
|
|
26 import dwtx.jface.dialogs.MessageDialogWithToggle;
|
|
27 import dwtx.jface.dialogs.MessageDialog;
|
|
28 import dwtx.jface.dialogs.IDialogConstants;
|
|
29 import dwtx.jface.dialogs.TitleAreaDialog;
|
|
30 import dwtx.jface.dialogs.InputDialog;
|
|
31 import dwtx.jface.dialogs.IMessageProvider;
|
|
32 import dwtx.jface.dialogs.DialogTray;
|
147
|
33
|
|
34 import dwtx.jface.window.ApplicationWindow;
|
149
|
35 import dwtx.core.runtime.IStatus;
|
|
36 import dwtx.core.runtime.Status;
|
|
37 import dwtx.core.runtime.MultiStatus;
|
|
38
|
|
39 version(JIVE) import jive.stacktrace;
|
147
|
40
|
|
41 class App : ApplicationWindow {
|
|
42
|
|
43 this(){
|
|
44 super(null);
|
|
45 setBlockOnOpen(true);
|
|
46 }
|
|
47 protected override Control createContents(Composite parent) {
|
|
48 Composite comp = cast(Composite)super.createContents(parent);
|
|
49 getShell().setText("Test PopupDialog");
|
|
50
|
|
51 comp.setLayout(new GridLayout(1, false));
|
|
52
|
|
53
|
149
|
54 with( new Button( comp, DWT.PUSH )){
|
|
55 addListener( DWT.Selection, dgListener( & doPopUp ));
|
|
56 setText( "PopUp" );
|
|
57 }
|
|
58 with( new Button( comp, DWT.PUSH )){
|
|
59 addListener( DWT.Selection, dgListener( & doErrorDlg ));
|
|
60 setText( "Error DLG" );
|
|
61 }
|
|
62 with( new Button( comp, DWT.PUSH )){
|
|
63 addListener( DWT.Selection, dgListener( & doInputDlg ));
|
|
64 setText( "Input DLG" );
|
|
65 }
|
|
66 with( new Button( comp, DWT.PUSH )){
|
|
67 addListener( DWT.Selection, dgListener( & doMessageDialogWithToggleDlg ));
|
|
68 setText( "MessageDialogWithToggle" );
|
|
69 }
|
|
70 with( new Button( comp, DWT.PUSH )){
|
|
71 addListener( DWT.Selection, dgListener( & doTitleAreaDialog ));
|
|
72 setText( "TitleAreaDialog" );
|
|
73 }
|
147
|
74 return comp;
|
|
75 }
|
149
|
76 void doPopUp( Event e ){
|
147
|
77 auto pu = new PopupDialog(
|
|
78 getShell(),
|
|
79 PopupDialog.HOVER_SHELLSTYLE ,
|
|
80 true,
|
|
81 true,
|
|
82 true,
|
|
83 true,
|
|
84 true,
|
|
85 "Title",
|
|
86 "Info line...");
|
|
87 pu.open();
|
|
88 }
|
149
|
89 void doErrorDlg( Event e ){
|
|
90 auto status = new MultiStatus( "plugin-ID", 0, "MultiStatus message", null );
|
|
91 status.add( new Status( Status.ERROR, "plugin-ID", "Status message 'error'"/+, new RuntimeException("bla")+/ ) );
|
|
92 status.add( new Status( Status.WARNING, "plugin-ID", "Status message 'warning'" ) );
|
|
93 auto dlg = new ErrorDialog(
|
|
94 getShell(),
|
|
95 "Title",
|
|
96 "Dialog message",
|
|
97 status,
|
|
98 IStatus.ERROR|IStatus.WARNING);
|
|
99 dlg.open();
|
|
100 }
|
|
101 void doMessageDialogWithToggleDlg( Event e ){
|
|
102 auto dlg = new MessageDialogWithToggle(
|
147
|
103 getShell(),
|
|
104 "Title",
|
149
|
105 null,
|
|
106 "Dialog message",
|
|
107 MessageDialog.INFORMATION,
|
|
108 [ IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL ],
|
|
109 0,
|
|
110 "Toggle message",
|
|
111 true);
|
|
112 dlg.open();
|
|
113 }
|
|
114 void doInputDlg( Event e ){
|
|
115 auto dlg = new InputDialog(
|
|
116 getShell(),
|
|
117 "Title",
|
|
118 "Dialog message",
|
|
119 "42",
|
|
120 null );
|
|
121 dlg.open();
|
|
122 }
|
|
123
|
|
124 void doTitleAreaDialog( Event e ){
|
|
125 auto dlg = new MyTitleAreaDialog(
|
|
126 getShell());
|
|
127 dlg.open();
|
147
|
128 }
|
|
129
|
|
130 }
|
|
131
|
149
|
132 class MyTitleAreaDialog : TitleAreaDialog {
|
|
133 this( Shell shell ){
|
|
134 super(shell);
|
|
135 }
|
|
136 protected override void configureShell(Shell newShell){
|
|
137 super.configureShell(newShell);
|
|
138 newShell.setText( "Application Name" );
|
|
139 }
|
|
140 protected override bool isResizable(){
|
|
141 return true;
|
|
142 }
|
|
143 protected override Control createContents(Composite parent) {
|
|
144 auto comp = cast(Composite) super.createContents(parent);
|
|
145 openTray( new MyTray() );
|
|
146 setTitle( "Title" );
|
|
147 setMessage( "A custom message", IMessageProvider.INFORMATION );
|
|
148 return comp;
|
|
149 }
|
|
150 protected override Control createDialogArea(Composite parent){
|
|
151 auto comp = cast(Composite) super.createDialogArea(parent);
|
|
152 //comp.setLayout( new FillLayout());
|
|
153 auto lbl = new Label( comp, DWT.None );
|
|
154 lbl.setText( "Dialog Area" );
|
|
155 auto gd = new GridData( GridData.FILL, GridData.FILL, true, false );
|
|
156 gd.verticalIndent = 5;
|
|
157 gd.horizontalIndent = 5;
|
|
158 lbl.setLayoutData( gd );
|
|
159 return comp;
|
|
160 }
|
|
161 }
|
|
162 class MyTray : DialogTray {
|
|
163 protected Control createContents(Composite parent){
|
|
164 auto comp = new Composite(parent, DWT.NONE );
|
|
165 comp.setLayout( new GridLayout( 1, false ));
|
|
166 with( new Label( comp, DWT.NONE )){
|
|
167 auto gd = new GridData( GridData.FILL, GridData.FILL, true, false );
|
|
168 gd.verticalIndent = 5;
|
|
169 gd.horizontalIndent = 5;
|
|
170 setLayoutData( gd );
|
|
171 setText( "Tray" );
|
|
172 }
|
|
173 return comp;
|
|
174 }
|
|
175 }
|
147
|
176
|
|
177
|
|
178 void main(){
|
|
179 auto d = new Display();
|
|
180 auto app = new App();
|
|
181 app.open();
|
|
182 }
|
|
183
|
|
184
|
|
185
|
|
186
|