Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 151412 Details for
Bug 253105
[templates] RCP Mail 2.0
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Use commands for RCP mail example (starting with Eclipse 3.4)
253105_mail_template_commands_2.txt (text/plain), 26.74 KB, created by
Ralf Ebert
on 2009-11-05 08:32:42 EST
(
hide
)
Description:
Use commands for RCP mail example (starting with Eclipse 3.4)
Filename:
MIME Type:
Creator:
Ralf Ebert
Created:
2009-11-05 08:32:42 EST
Size:
26.74 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.ui.templates >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui.templates/META-INF/MANIFEST.MF,v >retrieving revision 1.8 >diff -u -r1.8 MANIFEST.MF >--- META-INF/MANIFEST.MF 18 Aug 2008 15:52:18 -0000 1.8 >+++ META-INF/MANIFEST.MF 5 Nov 2009 13:33:02 -0000 >@@ -2,7 +2,7 @@ > Bundle-ManifestVersion: 2 > Bundle-Name: %bundleName > Bundle-SymbolicName: org.eclipse.pde.ui.templates;singleton:=true >-Bundle-Version: 3.4.100.qualifier >+Bundle-Version: 3.6.0.qualifier > Bundle-Vendor: %bundleVendor > Bundle-RequiredExecutionEnvironment: J2SE-1.4 > Export-Package: org.eclipse.pde.internal.ui.templates;x-internal:=true, >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui.templates/plugin.properties,v >retrieving revision 1.17 >diff -u -r1.17 plugin.properties >--- plugin.properties 21 Sep 2009 14:18:43 -0000 1.17 >+++ plugin.properties 5 Nov 2009 13:33:02 -0000 >@@ -103,8 +103,8 @@ > pluginContent.mail.name = RCP Mail Template > pluginContent.mail.description=\ > <p>This wizard creates a standalone RCP application that shows how to:</p>\ >-<li>add top-level menu and toolbar with actions</li>\ >-<li>add keybindings to actions</li>\ >+<li>add top-level menu and toolbar with actions (since 3.4 with commands)</li>\ >+<li>add keybindings to actions (since 3.4 to commands)</li>\ > <li>create views that can't be closed and multiple instances of the same view</li>\ > <li>create perspectives with placeholders for new views</li>\ > <li>use the default About dialog</li>\ >@@ -113,6 +113,7 @@ > <li>org.eclipse.core.runtime.applications</li>\ > <li>org.eclipse.core.runtime.products</li>\ > <li>org.eclipse.ui.commands</li>\ >+<li>org.eclipse.ui.menus (since 3.4)</li>\ > <li>org.eclipse.ui.perspectives</li>\ > <li>org.eclipse.ui.views</li> > >Index: src/org/eclipse/pde/internal/ui/templates/rcp/MailTemplate.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/rcp/MailTemplate.java,v >retrieving revision 1.7 >diff -u -r1.7 MailTemplate.java >--- src/org/eclipse/pde/internal/ui/templates/rcp/MailTemplate.java 27 Dec 2007 20:01:36 -0000 1.7 >+++ src/org/eclipse/pde/internal/ui/templates/rcp/MailTemplate.java 5 Nov 2009 13:33:02 -0000 >@@ -14,16 +14,12 @@ > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.jface.wizard.Wizard; > import org.eclipse.jface.wizard.WizardPage; >-import org.eclipse.pde.core.plugin.IPluginBase; >-import org.eclipse.pde.core.plugin.IPluginElement; >-import org.eclipse.pde.core.plugin.IPluginExtension; >-import org.eclipse.pde.core.plugin.IPluginModelBase; >-import org.eclipse.pde.core.plugin.IPluginReference; >-import org.eclipse.pde.internal.ui.templates.IHelpContextIds; >-import org.eclipse.pde.internal.ui.templates.PDETemplateMessages; >-import org.eclipse.pde.internal.ui.templates.PDETemplateSection; >+import org.eclipse.pde.core.plugin.*; >+import org.eclipse.pde.internal.ui.templates.*; > import org.eclipse.pde.ui.IFieldData; > import org.eclipse.pde.ui.templates.PluginReference; >+import org.eclipse.ui.IWorkbenchActionConstants; >+import org.eclipse.ui.menus.MenuUtil; > > public class MailTemplate extends PDETemplateSection { > >@@ -79,11 +75,16 @@ > createApplicationExtension(); > createPerspectiveExtension(); > createViewExtension(); >- if (getTargetVersion() >= 3.1) { >- createCommandExtension(false); >+ >+ boolean useKeyBindings = (getTargetVersion() >= 3.1); >+ boolean useCommandsOnly = (getTargetVersion() >= 3.4); >+ >+ createCommandExtension(!useKeyBindings, useCommandsOnly); >+ if (useKeyBindings) { > createBindingsExtension(); >- } else { >- createCommandExtension(true); >+ } >+ if (useCommandsOnly) { >+ createUiMenuExtension(); > } > createProductExtension(); > } >@@ -149,7 +150,7 @@ > plugin.add(extension); > } > >- private void createCommandExtension(boolean generateKeyBindings) throws CoreException { >+ private void createCommandExtension(boolean generateOldKeyBindings, boolean useCommandsOnly) throws CoreException { > IPluginBase plugin = model.getPluginBase(); > String id = plugin.getId(); > IPluginExtension extension = createExtension("org.eclipse.ui.commands", true); //$NON-NLS-1$ >@@ -162,8 +163,14 @@ > > element = model.getPluginFactory().createElement(extension); > element.setName("command"); //$NON-NLS-1$ >- element.setAttribute("description", "Opens a mailbox"); //$NON-NLS-1$ //$NON-NLS-2$ >- element.setAttribute("name", "Open Mailbox"); //$NON-NLS-1$ //$NON-NLS-2$ >+ if (useCommandsOnly) { >+ element.setAttribute("description", "Opens Another Message View"); //$NON-NLS-1$ //$NON-NLS-2$ >+ element.setAttribute("name", "Open Another Message View"); //$NON-NLS-1$ //$NON-NLS-2$ >+ element.setAttribute("defaultHandler", getStringOption(KEY_PACKAGE_NAME) + ".OpenViewHandler"); //$NON-NLS-1$ //$NON-NLS-2$ >+ } else { >+ element.setAttribute("description", "Opens a mailbox"); //$NON-NLS-1$ //$NON-NLS-2$ >+ element.setAttribute("name", "Open Mailbox"); //$NON-NLS-1$ //$NON-NLS-2$ >+ } > element.setAttribute("id", id + ".open"); //$NON-NLS-1$ //$NON-NLS-2$ > element.setAttribute("categoryId", id + ".category"); //$NON-NLS-1$ //$NON-NLS-2$ > extension.add(element); >@@ -174,9 +181,12 @@ > element.setAttribute("name", "Open Message Dialog"); //$NON-NLS-1$ //$NON-NLS-2$ > element.setAttribute("id", id + ".openMessage"); //$NON-NLS-1$ //$NON-NLS-2$ > element.setAttribute("categoryId", id + ".category"); //$NON-NLS-1$ //$NON-NLS-2$ >+ if (useCommandsOnly) { >+ element.setAttribute("defaultHandler", getStringOption(KEY_PACKAGE_NAME) + ".OpenMessageHandler"); //$NON-NLS-1$ //$NON-NLS-2$ >+ } > extension.add(element); > >- if (generateKeyBindings) { >+ if (generateOldKeyBindings) { > element = model.getPluginFactory().createElement(extension); > element.setName("keyConfiguration"); //$NON-NLS-1$ > element.setAttribute("description", "The key configuration for this sample"); //$NON-NLS-1$ //$NON-NLS-2$ >@@ -218,21 +228,21 @@ > IPluginElement element = model.getPluginFactory().createElement(extension); > element.setName("key"); //$NON-NLS-1$ > element.setAttribute("commandId", id + ".open"); //$NON-NLS-1$ //$NON-NLS-2$ >- element.setAttribute("sequence", "CTRL+2"); //$NON-NLS-1$ //$NON-NLS-2$ >+ element.setAttribute("sequence", "M1+2"); //$NON-NLS-1$ //$NON-NLS-2$ > element.setAttribute("schemeId", "org.eclipse.ui.defaultAcceleratorConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ > extension.add(element); > > element = model.getPluginFactory().createElement(extension); > element.setName("key"); //$NON-NLS-1$ > element.setAttribute("commandId", id + ".openMessage"); //$NON-NLS-1$ //$NON-NLS-2$ >- element.setAttribute("sequence", "CTRL+3"); //$NON-NLS-1$ //$NON-NLS-2$ >+ element.setAttribute("sequence", "M1+3"); //$NON-NLS-1$ //$NON-NLS-2$ > element.setAttribute("schemeId", "org.eclipse.ui.defaultAcceleratorConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ > extension.add(element); > > element = model.getPluginFactory().createElement(extension); > element.setName("key"); //$NON-NLS-1$ > element.setAttribute("commandId", "org.eclipse.ui.file.exit"); //$NON-NLS-1$ //$NON-NLS-2$ >- element.setAttribute("sequence", "CTRL+X"); //$NON-NLS-1$ //$NON-NLS-2$ >+ element.setAttribute("sequence", "M1+X"); //$NON-NLS-1$ //$NON-NLS-2$ > element.setAttribute("schemeId", "org.eclipse.ui.defaultAcceleratorConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ > extension.add(element); > >@@ -240,6 +250,73 @@ > plugin.add(extension); > } > >+ private void createUiMenuExtension() throws CoreException { >+ IPluginBase plugin = model.getPluginBase(); >+ String id = plugin.getId(); >+ IPluginExtension extension = createExtension("org.eclipse.ui.menus", true); //$NON-NLS-1$ >+ >+ IPluginElement menuContribution = model.getPluginFactory().createElement(extension); >+ menuContribution.setName("menuContribution"); //$NON-NLS-1$ >+ menuContribution.setAttribute("locationURI", MenuUtil.MAIN_MENU); //$NON-NLS-1$ >+ extension.add(menuContribution); >+ >+ IPluginElement fileMenu = model.getPluginFactory().createElement(extension); >+ fileMenu.setName("menu"); //$NON-NLS-1$ >+ fileMenu.setAttribute("id", IWorkbenchActionConstants.M_FILE); //$NON-NLS-1$ >+ fileMenu.setAttribute("label", "&File"); //$NON-NLS-1$ //$NON-NLS-2$ >+ menuContribution.add(fileMenu); >+ >+ addMenuCommandElement(model, fileMenu, "org.eclipse.ui.window.newWindow", null); //$NON-NLS-1$ >+ addMenuSeparatorElement(model, fileMenu, IWorkbenchActionConstants.M_FILE + ".separator1"); //$NON-NLS-1$ >+ addMenuCommandElement(model, fileMenu, id + ".openMessage", "icons/sample3.gif"); //$NON-NLS-1$ //$NON-NLS-2$ >+ addMenuCommandElement(model, fileMenu, id + ".open", "icons/sample2.gif"); //$NON-NLS-1$ //$NON-NLS-2$ >+ addMenuSeparatorElement(model, fileMenu, IWorkbenchActionConstants.M_FILE + ".separator2"); //$NON-NLS-1$ >+ addMenuCommandElement(model, fileMenu, "org.eclipse.ui.file.exit", null); //$NON-NLS-1$ >+ >+ IPluginElement helpMenu = model.getPluginFactory().createElement(extension); >+ helpMenu.setName("menu"); //$NON-NLS-1$ >+ helpMenu.setAttribute("id", IWorkbenchActionConstants.M_HELP); //$NON-NLS-1$ >+ helpMenu.setAttribute("label", "&Help"); //$NON-NLS-1$ //$NON-NLS-2$ >+ menuContribution.add(helpMenu); >+ >+ addMenuCommandElement(model, helpMenu, "org.eclipse.ui.help.aboutAction", null); //$NON-NLS-1$ >+ >+ IPluginElement toolbarContribution = model.getPluginFactory().createElement(extension); >+ toolbarContribution.setName("menuContribution"); //$NON-NLS-1$ >+ toolbarContribution.setAttribute("locationURI", MenuUtil.MAIN_TOOLBAR); //$NON-NLS-1$ >+ extension.add(toolbarContribution); >+ >+ IPluginElement mainToolbar = model.getPluginFactory().createElement(extension); >+ mainToolbar.setName("toolbar"); //$NON-NLS-1$ >+ mainToolbar.setAttribute("id", "main"); //$NON-NLS-1$ //$NON-NLS-2$ >+ toolbarContribution.add(mainToolbar); >+ >+ addMenuCommandElement(model, mainToolbar, id + ".openMessage", "icons/sample3.gif"); //$NON-NLS-1$ //$NON-NLS-2$ >+ addMenuCommandElement(model, mainToolbar, id + ".open", "icons/sample2.gif"); //$NON-NLS-1$ //$NON-NLS-2$ >+ >+ if (!extension.isInTheModel()) >+ plugin.add(extension); >+ } >+ >+ private void addMenuCommandElement(IPluginModelBase model, IPluginElement menuElement, String commandId, String icon) throws CoreException { >+ IPluginElement commandElement = model.getPluginFactory().createElement(menuElement); >+ commandElement.setName("command"); //$NON-NLS-1$ >+ commandElement.setAttribute("commandId", commandId); //$NON-NLS-1$ >+ commandElement.setAttribute("style", "push"); //$NON-NLS-1$ //$NON-NLS-2$ >+ if (icon != null) { >+ commandElement.setAttribute("icon", icon); //$NON-NLS-1$ >+ } >+ menuElement.add(commandElement); >+ } >+ >+ private void addMenuSeparatorElement(IPluginModelBase model, IPluginElement menuElement, String name) throws CoreException { >+ IPluginElement commandElement = model.getPluginFactory().createElement(menuElement); >+ commandElement.setName("separator"); //$NON-NLS-1$ >+ commandElement.setAttribute("name", name); //$NON-NLS-1$ >+ commandElement.setAttribute("visible", "true"); //$NON-NLS-1$ //$NON-NLS-2$ >+ menuElement.add(commandElement); >+ } >+ > private void createProductExtension() throws CoreException { > IPluginBase plugin = model.getPluginBase(); > IPluginExtension extension = createExtension("org.eclipse.core.runtime.products", true); //$NON-NLS-1$ >Index: templates_3.4/mail/java/$applicationClass$.java >=================================================================== >RCS file: templates_3.4/mail/java/$applicationClass$.java >diff -N templates_3.4/mail/java/$applicationClass$.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ templates_3.4/mail/java/$applicationClass$.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,45 @@ >+package $packageName$; >+ >+import org.eclipse.equinox.app.IApplication; >+import org.eclipse.equinox.app.IApplicationContext; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.ui.PlatformUI; >+ >+/** >+ * This class controls all aspects of the application's execution >+ */ >+public class $applicationClass$ implements IApplication { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) >+ */ >+ public Object start(IApplicationContext context) { >+ Display display = PlatformUI.createDisplay(); >+ try { >+ int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); >+ if (returnCode == PlatformUI.RETURN_RESTART) { >+ return IApplication.EXIT_RESTART; >+ } >+ return IApplication.EXIT_OK; >+ } finally { >+ display.dispose(); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.equinox.app.IApplication#stop() >+ */ >+ public void stop() { >+ if (!PlatformUI.isWorkbenchRunning()) >+ return; >+ final IWorkbench workbench = PlatformUI.getWorkbench(); >+ final Display display = workbench.getDisplay(); >+ display.syncExec(new Runnable() { >+ public void run() { >+ if (!display.isDisposed()) >+ workbench.close(); >+ } >+ }); >+ } >+} >Index: templates_3.4/mail/java/ApplicationWorkbenchAdvisor.java >=================================================================== >RCS file: templates_3.4/mail/java/ApplicationWorkbenchAdvisor.java >diff -N templates_3.4/mail/java/ApplicationWorkbenchAdvisor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ templates_3.4/mail/java/ApplicationWorkbenchAdvisor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+package $packageName$; >+ >+import org.eclipse.ui.application.IWorkbenchWindowConfigurer; >+import org.eclipse.ui.application.WorkbenchAdvisor; >+import org.eclipse.ui.application.WorkbenchWindowAdvisor; >+ >+/** >+ * This workbench advisor creates the window advisor, and specifies >+ * the perspective id for the initial window. >+ */ >+public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { >+ >+ public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { >+ return new ApplicationWorkbenchWindowAdvisor(configurer); >+ } >+ >+ public String getInitialWindowPerspectiveId() { >+ return Perspective.ID; >+ } >+ >+} >Index: templates_3.4/mail/java/ApplicationWorkbenchWindowAdvisor.java >=================================================================== >RCS file: templates_3.4/mail/java/ApplicationWorkbenchWindowAdvisor.java >diff -N templates_3.4/mail/java/ApplicationWorkbenchWindowAdvisor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ templates_3.4/mail/java/ApplicationWorkbenchWindowAdvisor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,20 @@ >+package $packageName$; >+ >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.ui.application.IWorkbenchWindowConfigurer; >+import org.eclipse.ui.application.WorkbenchWindowAdvisor; >+ >+public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { >+ >+ public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { >+ super(configurer); >+ } >+ >+ public void preWindowOpen() { >+ IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); >+ configurer.setInitialSize(new Point(600, 400)); >+ configurer.setShowCoolBar(true); >+ configurer.setShowStatusLine(false); >+ } >+ >+} >Index: templates_3.4/mail/java/ICommandIds.java >=================================================================== >RCS file: templates_3.4/mail/java/ICommandIds.java >diff -N templates_3.4/mail/java/ICommandIds.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ templates_3.4/mail/java/ICommandIds.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,15 @@ >+package $packageName$; >+ >+/** >+ * Interface defining the application's command IDs. >+ * Key bindings can be defined for specific commands. >+ * To associate an action with a command, use IAction.setActionDefinitionId(commandId). >+ * >+ * @see org.eclipse.jface.action.IAction#setActionDefinitionId(String) >+ */ >+public interface ICommandIds { >+ >+ public static final String CMD_OPEN = "$pluginId$.open"; >+ public static final String CMD_OPEN_MESSAGE = "$pluginId$.openMessage"; >+ >+} >Index: templates_3.4/mail/java/NavigationView.java >=================================================================== >RCS file: templates_3.4/mail/java/NavigationView.java >diff -N templates_3.4/mail/java/NavigationView.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ templates_3.4/mail/java/NavigationView.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,151 @@ >+package $packageName$; >+ >+import java.util.ArrayList; >+ >+import org.eclipse.jface.viewers.IStructuredContentProvider; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jface.viewers.TreeViewer; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.ISharedImages; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.part.ViewPart; >+ >+public class NavigationView extends ViewPart { >+ public static final String ID = "$pluginId$.navigationView"; >+ private TreeViewer viewer; >+ >+ class TreeObject { >+ private String name; >+ private TreeParent parent; >+ >+ public TreeObject(String name) { >+ this.name = name; >+ } >+ public String getName() { >+ return name; >+ } >+ public void setParent(TreeParent parent) { >+ this.parent = parent; >+ } >+ public TreeParent getParent() { >+ return parent; >+ } >+ public String toString() { >+ return getName(); >+ } >+ } >+ >+ class TreeParent extends TreeObject { >+ private ArrayList children; >+ public TreeParent(String name) { >+ super(name); >+ children = new ArrayList(); >+ } >+ public void addChild(TreeObject child) { >+ children.add(child); >+ child.setParent(this); >+ } >+ public void removeChild(TreeObject child) { >+ children.remove(child); >+ child.setParent(null); >+ } >+ public TreeObject[] getChildren() { >+ return (TreeObject[]) children.toArray(new TreeObject[children.size()]); >+ } >+ public boolean hasChildren() { >+ return children.size()>0; >+ } >+ } >+ >+ class ViewContentProvider implements IStructuredContentProvider, >+ ITreeContentProvider { >+ >+ public void inputChanged(Viewer v, Object oldInput, Object newInput) { >+ } >+ >+ public void dispose() { >+ } >+ >+ public Object[] getElements(Object parent) { >+ return getChildren(parent); >+ } >+ >+ public Object getParent(Object child) { >+ if (child instanceof TreeObject) { >+ return ((TreeObject)child).getParent(); >+ } >+ return null; >+ } >+ >+ public Object[] getChildren(Object parent) { >+ if (parent instanceof TreeParent) { >+ return ((TreeParent)parent).getChildren(); >+ } >+ return new Object[0]; >+ } >+ >+ public boolean hasChildren(Object parent) { >+ if (parent instanceof TreeParent) >+ return ((TreeParent)parent).hasChildren(); >+ return false; >+ } >+ } >+ >+ class ViewLabelProvider extends LabelProvider { >+ >+ public String getText(Object obj) { >+ return obj.toString(); >+ } >+ public Image getImage(Object obj) { >+ String imageKey = ISharedImages.IMG_OBJ_ELEMENT; >+ if (obj instanceof TreeParent) >+ imageKey = ISharedImages.IMG_OBJ_FOLDER; >+ return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey); >+ } >+ } >+ >+ /** >+ * We will set up a dummy model to initialize tree heararchy. In real >+ * code, you will connect to a real model and expose its hierarchy. >+ */ >+ private TreeObject createDummyModel() { >+ TreeObject to1 = new TreeObject("Inbox"); >+ TreeObject to2 = new TreeObject("Drafts"); >+ TreeObject to3 = new TreeObject("Sent"); >+ TreeParent p1 = new TreeParent("me@this.com"); >+ p1.addChild(to1); >+ p1.addChild(to2); >+ p1.addChild(to3); >+ >+ TreeObject to4 = new TreeObject("Inbox"); >+ TreeParent p2 = new TreeParent("other@aol.com"); >+ p2.addChild(to4); >+ >+ TreeParent root = new TreeParent(""); >+ root.addChild(p1); >+ root.addChild(p2); >+ return root; >+ } >+ >+ /** >+ * This is a callback that will allow us to create the viewer and initialize >+ * it. >+ */ >+ public void createPartControl(Composite parent) { >+ viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); >+ viewer.setContentProvider(new ViewContentProvider()); >+ viewer.setLabelProvider(new ViewLabelProvider()); >+ viewer.setInput(createDummyModel()); >+ } >+ >+ /** >+ * Passing the focus request to the viewer's control. >+ */ >+ public void setFocus() { >+ viewer.getControl().setFocus(); >+ } >+} >\ No newline at end of file >Index: templates_3.4/mail/java/OpenMessageHandler.java >=================================================================== >RCS file: templates_3.4/mail/java/OpenMessageHandler.java >diff -N templates_3.4/mail/java/OpenMessageHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ templates_3.4/mail/java/OpenMessageHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,15 @@ >+package $packageName$; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.ui.handlers.HandlerUtil; >+ >+public class OpenMessageHandler extends AbstractHandler { >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "Open", "Open Message Dialog!"); >+ return null; >+ } >+} >\ No newline at end of file >Index: templates_3.4/mail/java/OpenViewHandler.java >=================================================================== >RCS file: templates_3.4/mail/java/OpenViewHandler.java >diff -N templates_3.4/mail/java/OpenViewHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ templates_3.4/mail/java/OpenViewHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,28 @@ >+package $packageName$; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.handlers.HandlerUtil; >+ >+public class OpenViewHandler extends AbstractHandler { >+ >+ private int instanceNum = 0; >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ >+ IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); >+ >+ try { >+ window.getActivePage().showView(View.ID, Integer.toString(instanceNum++), IWorkbenchPage.VIEW_ACTIVATE); >+ } catch (PartInitException e) { >+ MessageDialog.openError(window.getShell(), "Error", "Error opening view:" + e.getMessage()); >+ } >+ >+ return null; >+ } >+} >Index: templates_3.4/mail/java/Perspective.java >=================================================================== >RCS file: templates_3.4/mail/java/Perspective.java >diff -N templates_3.4/mail/java/Perspective.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ templates_3.4/mail/java/Perspective.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,25 @@ >+package $packageName$; >+ >+import org.eclipse.ui.IFolderLayout; >+import org.eclipse.ui.IPageLayout; >+import org.eclipse.ui.IPerspectiveFactory; >+ >+public class Perspective implements IPerspectiveFactory { >+ >+ /** >+ * The ID of the perspective as specified in the extension. >+ */ >+ public static final String ID = "$pluginId$.perspective"; >+ >+ public void createInitialLayout(IPageLayout layout) { >+ String editorArea = layout.getEditorArea(); >+ layout.setEditorAreaVisible(false); >+ >+ layout.addStandaloneView(NavigationView.ID, false, IPageLayout.LEFT, 0.25f, editorArea); >+ IFolderLayout folder = layout.createFolder("messages", IPageLayout.TOP, 0.5f, editorArea); >+ folder.addPlaceholder(View.ID + ":*"); >+ folder.addView(View.ID); >+ >+ layout.getViewLayout(NavigationView.ID).setCloseable(false); >+ } >+} >Index: templates_3.4/mail/java/View.java >=================================================================== >RCS file: templates_3.4/mail/java/View.java >diff -N templates_3.4/mail/java/View.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ templates_3.4/mail/java/View.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,77 @@ >+package $packageName$; >+ >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.resource.JFaceResources; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Link; >+import org.eclipse.swt.widgets.Text; >+import org.eclipse.ui.part.ViewPart; >+ >+public class View extends ViewPart { >+ >+ public static final String ID = "$pluginId$.view"; >+ >+ public void createPartControl(Composite parent) { >+ Composite top = new Composite(parent, SWT.NONE); >+ GridLayout layout = new GridLayout(); >+ layout.marginHeight = 0; >+ layout.marginWidth = 0; >+ top.setLayout(layout); >+ // top banner >+ Composite banner = new Composite(top, SWT.NONE); >+ banner.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_BEGINNING, true, false)); >+ layout = new GridLayout(); >+ layout.marginHeight = 5; >+ layout.marginWidth = 10; >+ layout.numColumns = 2; >+ banner.setLayout(layout); >+ >+ // setup bold font >+ Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT); >+ >+ Label l = new Label(banner, SWT.WRAP); >+ l.setText("Subject:"); >+ l.setFont(boldFont); >+ l = new Label(banner, SWT.WRAP); >+ l.setText("This is a message about the cool Eclipse RCP!"); >+ >+ l = new Label(banner, SWT.WRAP); >+ l.setText("From:"); >+ l.setFont(boldFont); >+ >+ final Link link = new Link(banner, SWT.NONE); >+ link.setText("<a>nicole@mail.org</a>"); >+ link.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ MessageDialog.openInformation(getSite().getShell(), "Not Implemented", "Imagine the address book or a new message being created now."); >+ } >+ }); >+ >+ l = new Label(banner, SWT.WRAP); >+ l.setText("Date:"); >+ l.setFont(boldFont); >+ l = new Label(banner, SWT.WRAP); >+ l.setText("10:34 am"); >+ // message contents >+ Text text = new Text(top, SWT.MULTI | SWT.WRAP); >+ text.setText("This RCP Application was generated from the PDE Plug-in Project wizard. This sample shows how to:\n"+ >+ "- add a top-level menu and toolbar with commands\n"+ >+ "- add keybindings to commands\n" + >+ "- create views that can't be closed and\n"+ >+ " multiple instances of the same view\n"+ >+ "- perspectives with placeholders for new views\n"+ >+ "- use the default about dialog\n"+ >+ "- create a product definition\n"); >+ text.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ } >+ >+ public void setFocus() { >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 253105
:
150990
|
151412
|
163316
|
163317
|
163368
|
163370