11package de .vogella .rcp .dialogs .swt ;
22
33import org .eclipse .swt .SWT ;
4- import org .eclipse .swt .events .SelectionAdapter ;
5- import org .eclipse .swt .events .SelectionEvent ;
6- import org .eclipse .swt .graphics .FontData ;
7- import org .eclipse .swt .graphics .RGB ;
8- import org .eclipse .swt .widgets .Button ;
9- import org .eclipse .swt .widgets .ColorDialog ;
104import org .eclipse .swt .widgets .Composite ;
11- import org .eclipse .swt .widgets .DirectoryDialog ;
12- import org .eclipse .swt .widgets .FileDialog ;
13- import org .eclipse .swt .widgets .FontDialog ;
14- import org .eclipse .swt .widgets .MessageBox ;
15- import org .eclipse .swt .widgets .Shell ;
165import org .eclipse .ui .part .ViewPart ;
176
187public class View extends ViewPart {
@@ -21,62 +10,13 @@ public class View extends ViewPart {
2110
2211 @ Override
2312 public void createPartControl (Composite parent ) {
24- Button button = new Button (parent , SWT .PUSH );
25- button .addSelectionListener (new SelectionAdapter () {
26- @ Override
27- public void widgetSelected (SelectionEvent e ) {
28- Shell shell = getViewSite ().getShell ();
29- // File standard dialog
30- FileDialog fileDialog = new FileDialog (shell );
31- // Set the text
32- fileDialog .setText ("Select File" );
33- // Set filter on .txt files
34- fileDialog .setFilterExtensions (new String [] { "*.txt" });
35- // Put in a readable name for the filter
36- fileDialog .setFilterNames (new String [] { "Textfiles(*.txt)" });
37- // Open Dialog and save result of selection
38- String selected = fileDialog .open ();
39- System .out .println (selected );
13+ new MyComposite (parent , SWT .NONE );
4014
41- // Directly standard selection
42- DirectoryDialog dirDialog = new DirectoryDialog (shell );
43- dirDialog .setText ("Select your home directory" );
44- String selectedDir = dirDialog .open ();
45- System .out .println (selectedDir );
46-
47- // Select Font
48- FontDialog fontDialog = new FontDialog (shell );
49- fontDialog .setText ("Select your favorite font" );
50- FontData selectedFont = fontDialog .open ();
51- System .out .println (selectedFont );
52-
53- // Select Color
54- ColorDialog colorDialog = new ColorDialog (shell );
55- colorDialog .setText ("Select your favorite color" );
56- RGB selectedColor = colorDialog .open ();
57- System .out .println (selectedColor );
58-
59- // Message
60- MessageBox messageDialog = new MessageBox (shell , SWT .ERROR );
61- messageDialog .setText ("Evil Error has happend" );
62- messageDialog .setMessage ("This is fatal!!!" );
63- int returnCode = messageDialog .open ();
64- System .out .println (returnCode );
65-
66- // Message with ok and cancel button and info icon
67- messageDialog = new MessageBox (shell , SWT .ICON_QUESTION
68- | SWT .OK | SWT .CANCEL );
69- messageDialog .setText ("My info" );
70- messageDialog .setMessage ("Do you really want to do this." );
71- returnCode = messageDialog .open ();
72- System .out .println (returnCode );
73- }
74- });
7515 }
7616
7717 @ Override
7818 public void setFocus () {
79- // Set the focus
19+
8020 }
8121
8222}
0 commit comments