KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > $packageName$ > View


1 package $packageName$;
2
3 import org.eclipse.jface.dialogs.MessageDialog;
4 import org.eclipse.jface.resource.JFaceResources;
5 import org.eclipse.swt.SWT;
6 import org.eclipse.swt.events.SelectionAdapter;
7 import org.eclipse.swt.events.SelectionEvent;
8 import org.eclipse.swt.graphics.Font;
9 import org.eclipse.swt.layout.GridData;
10 import org.eclipse.swt.layout.GridLayout;
11 import org.eclipse.swt.widgets.Composite;
12 import org.eclipse.swt.widgets.Label;
13 import org.eclipse.swt.widgets.Link;
14 import org.eclipse.swt.widgets.Text;
15 import org.eclipse.ui.part.ViewPart;
16
17 public class View extends ViewPart {
18
19     public static final String JavaDoc ID = "$pluginId$.view";
20     
21     public void createPartControl(Composite parent) {
22         Composite top = new Composite(parent, SWT.NONE);
23         GridLayout layout = new GridLayout();
24         layout.marginHeight = 0;
25         layout.marginWidth = 0;
26         top.setLayout(layout);
27         // top banner
28
Composite banner = new Composite(top, SWT.NONE);
29         banner.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_BEGINNING, true, false));
30         layout = new GridLayout();
31         layout.marginHeight = 5;
32         layout.marginWidth = 10;
33         layout.numColumns = 2;
34         banner.setLayout(layout);
35         
36         // setup bold font
37
Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
38         
39         Label l = new Label(banner, SWT.WRAP);
40         l.setText("Subject:");
41         l.setFont(boldFont);
42         l = new Label(banner, SWT.WRAP);
43         l.setText("This is a message about the cool Eclipse RCP!");
44         
45         l = new Label(banner, SWT.WRAP);
46         l.setText("From:");
47         l.setFont(boldFont);
48     
49         final Link link = new Link(banner, SWT.NONE);
50         link.setText("<a>nicole@mail.org</a>");
51         link.addSelectionListener(new SelectionAdapter() {
52             public void widgetSelected(SelectionEvent e) {
53                 MessageDialog.openInformation(getSite().getShell(), "Not Implemented", "Imagine the address book or a new message being created now.");
54             }
55         });
56     
57         l = new Label(banner, SWT.WRAP);
58         l.setText("Date:");
59         l.setFont(boldFont);
60         l = new Label(banner, SWT.WRAP);
61         l.setText("10:34 am");
62         // message contents
63
Text text = new Text(top, SWT.MULTI | SWT.WRAP);
64         text.setText("This RCP Application was generated from the PDE Plug-in Project wizard. This sample shows how to:\n"+
65                         "- add a top-level menu and toolbar with actions\n"+
66                         "- add keybindings to actions\n" +
67                         "- create views that can't be closed and\n"+
68                         " multiple instances of the same view\n"+
69                         "- perspectives with placeholders for new views\n"+
70                         "- use the default about dialog\n"+
71                         "- create a product definition\n");
72         text.setLayoutData(new GridData(GridData.FILL_BOTH));
73     }
74
75     public void setFocus() {
76     }
77 }
78
Popular Tags