Initial version of project - RCP Mail Template.
authorp.ciardelli <p.ciardelli@localhost>
Wed, 15 Aug 2007 09:11:45 +0000 (09:11 +0000)
committerp.ciardelli <p.ciardelli@localhost>
Wed, 15 Aug 2007 09:11:45 +0000 (09:11 +0000)
24 files changed:
.classpath [new file with mode: 0644]
.gitattributes
.project [new file with mode: 0644]
META-INF/MANIFEST.MF [new file with mode: 0644]
build.properties [new file with mode: 0644]
icons/mail.ico [new file with mode: 0644]
icons/sample.gif [new file with mode: 0644]
icons/sample.icns [new file with mode: 0644]
icons/sample2.gif [new file with mode: 0644]
icons/sample3.gif [new file with mode: 0644]
plugin.xml [new file with mode: 0644]
product_lg.gif [new file with mode: 0644]
splash.bmp [new file with mode: 0644]
src/eu/etaxonomy/taxeditor/Activator.java [new file with mode: 0644]
src/eu/etaxonomy/taxeditor/ApplicationActionBarAdvisor.java [new file with mode: 0644]
src/eu/etaxonomy/taxeditor/ApplicationWorkbenchAdvisor.java [new file with mode: 0644]
src/eu/etaxonomy/taxeditor/ApplicationWorkbenchWindowAdvisor.java [new file with mode: 0644]
src/eu/etaxonomy/taxeditor/ICommandIds.java [new file with mode: 0644]
src/eu/etaxonomy/taxeditor/MessagePopupAction.java [new file with mode: 0644]
src/eu/etaxonomy/taxeditor/NavigationView.java [new file with mode: 0644]
src/eu/etaxonomy/taxeditor/OpenViewAction.java [new file with mode: 0644]
src/eu/etaxonomy/taxeditor/Perspective.java [new file with mode: 0644]
src/eu/etaxonomy/taxeditor/TaxEditorApplication.java [new file with mode: 0644]
src/eu/etaxonomy/taxeditor/View.java [new file with mode: 0644]

diff --git a/.classpath b/.classpath
new file mode 100644 (file)
index 0000000..0215967
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>\r
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
index 8e948c534a1fd79cf59d786adc75fec0a4d091d7..a18d3dd4ecddb815b9596560a74aabf6df581c3f 100644 (file)
@@ -1 +1,24 @@
 * text=auto !eol
 * text=auto !eol
+/.classpath -text
+/.project -text
+META-INF/MANIFEST.MF -text
+/build.properties -text
+icons/mail.ico -text
+icons/sample.gif -text
+icons/sample.icns -text
+icons/sample2.gif -text
+icons/sample3.gif -text
+/plugin.xml -text
+/product_lg.gif -text
+/splash.bmp -text
+src/eu/etaxonomy/taxeditor/Activator.java -text
+src/eu/etaxonomy/taxeditor/ApplicationActionBarAdvisor.java -text
+src/eu/etaxonomy/taxeditor/ApplicationWorkbenchAdvisor.java -text
+src/eu/etaxonomy/taxeditor/ApplicationWorkbenchWindowAdvisor.java -text
+src/eu/etaxonomy/taxeditor/ICommandIds.java -text
+src/eu/etaxonomy/taxeditor/MessagePopupAction.java -text
+src/eu/etaxonomy/taxeditor/NavigationView.java -text
+src/eu/etaxonomy/taxeditor/OpenViewAction.java -text
+src/eu/etaxonomy/taxeditor/Perspective.java -text
+src/eu/etaxonomy/taxeditor/TaxEditorApplication.java -text
+src/eu/etaxonomy/taxeditor/View.java -text
diff --git a/.project b/.project
new file mode 100644 (file)
index 0000000..4b68c1f
--- /dev/null
+++ b/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>eu.etaxonomy.taxeditor</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..85be423
--- /dev/null
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: eu.etaxonomy.taxeditor
+Bundle-SymbolicName: eu.etaxonomy.taxeditor; singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: eu.etaxonomy.taxeditor.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime
+Eclipse-LazyStart: true
diff --git a/build.properties b/build.properties
new file mode 100644 (file)
index 0000000..a19cb24
--- /dev/null
@@ -0,0 +1,8 @@
+source.. = src/\r
+output.. = bin/\r
+bin.includes = plugin.xml,\\r
+               META-INF/,\\r
+               .,\\r
+               icons/,\\r
+               product_lg.gif,\\r
+               splash.bmp\r
diff --git a/icons/mail.ico b/icons/mail.ico
new file mode 100644 (file)
index 0000000..b000061
Binary files /dev/null and b/icons/mail.ico differ
diff --git a/icons/sample.gif b/icons/sample.gif
new file mode 100644 (file)
index 0000000..34fb3c9
Binary files /dev/null and b/icons/sample.gif differ
diff --git a/icons/sample.icns b/icons/sample.icns
new file mode 100644 (file)
index 0000000..1e92ccc
Binary files /dev/null and b/icons/sample.icns differ
diff --git a/icons/sample2.gif b/icons/sample2.gif
new file mode 100644 (file)
index 0000000..252d7eb
Binary files /dev/null and b/icons/sample2.gif differ
diff --git a/icons/sample3.gif b/icons/sample3.gif
new file mode 100644 (file)
index 0000000..b949ac9
Binary files /dev/null and b/icons/sample3.gif differ
diff --git a/plugin.xml b/plugin.xml
new file mode 100644 (file)
index 0000000..4b3648b
--- /dev/null
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<?eclipse version="3.2"?>\r
+<plugin>\r
+\r
+   <extension\r
+         id="application"\r
+         point="org.eclipse.core.runtime.applications">\r
+      <application>\r
+         <run\r
+               class="eu.etaxonomy.taxeditor.TaxEditorApplication">\r
+         </run>\r
+      </application>\r
+   </extension>\r
+   <extension\r
+         point="org.eclipse.ui.perspectives">\r
+      <perspective\r
+            name="RCP Perspective"\r
+            class="eu.etaxonomy.taxeditor.Perspective"\r
+            id="eu.etaxonomy.taxeditor.perspective">\r
+      </perspective>\r
+   </extension>\r
+   <extension\r
+         point="org.eclipse.ui.views">\r
+      <view\r
+            name="Message"\r
+            allowMultiple="true"\r
+            icon="icons/sample2.gif"\r
+            class="eu.etaxonomy.taxeditor.View"\r
+            id="eu.etaxonomy.taxeditor.view">\r
+      </view>\r
+      <view\r
+            name="Mailboxes"\r
+            allowMultiple="true"\r
+            icon="icons/sample3.gif"\r
+            class="eu.etaxonomy.taxeditor.NavigationView"\r
+            id="eu.etaxonomy.taxeditor.navigationView">\r
+      </view>\r
+   </extension>\r
+   <extension\r
+         point="org.eclipse.ui.commands">\r
+      <category\r
+            name="Mail"\r
+            id="eu.etaxonomy.taxeditor.category">\r
+      </category>\r
+      <command\r
+            name="Open Mailbox"\r
+            description="Opens a mailbox"\r
+            categoryId="eu.etaxonomy.taxeditor.category"\r
+            id="eu.etaxonomy.taxeditor.open">\r
+      </command>\r
+      <command\r
+            name="Open Message Dialog"\r
+            description="Open a message dialog"\r
+            categoryId="eu.etaxonomy.taxeditor.category"\r
+            id="eu.etaxonomy.taxeditor.openMessage">\r
+      </command>\r
+   </extension>\r
+   <extension\r
+         point="org.eclipse.ui.bindings">\r
+      <key\r
+            commandId="eu.etaxonomy.taxeditor.open"\r
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"\r
+            sequence="CTRL+2">\r
+      </key>\r
+      <key\r
+            commandId="eu.etaxonomy.taxeditor.openMessage"\r
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"\r
+            sequence="CTRL+3">\r
+      </key>\r
+      <key\r
+            commandId="org.eclipse.ui.file.exit"\r
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"\r
+            sequence="CTRL+X">\r
+      </key>\r
+   </extension>\r
+   <extension\r
+         id="product"\r
+         point="org.eclipse.core.runtime.products">\r
+      <product\r
+            application="eu.etaxonomy.taxeditor.application"\r
+            name="Taxonomic Editor">\r
+         <property\r
+               name="aboutText"\r
+               value="RCP Mail template created by PDE">\r
+         </property>\r
+         <property\r
+               name="windowImages"\r
+               value="icons/sample2.gif">\r
+         </property>\r
+         <property\r
+               name="aboutImage"\r
+               value="product_lg.gif">\r
+         </property>\r
+      </product>\r
+   </extension>\r
+\r
+</plugin>\r
diff --git a/product_lg.gif b/product_lg.gif
new file mode 100644 (file)
index 0000000..bd95e28
Binary files /dev/null and b/product_lg.gif differ
diff --git a/splash.bmp b/splash.bmp
new file mode 100644 (file)
index 0000000..d7d2e30
Binary files /dev/null and b/splash.bmp differ
diff --git a/src/eu/etaxonomy/taxeditor/Activator.java b/src/eu/etaxonomy/taxeditor/Activator.java
new file mode 100644 (file)
index 0000000..883be15
--- /dev/null
@@ -0,0 +1,61 @@
+package eu.etaxonomy.taxeditor;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.eclipse.ui.plugin.AbstractUIPlugin;\r
+import org.osgi.framework.BundleContext;\r
+\r
+/**\r
+ * The activator class controls the plug-in life cycle\r
+ */\r
+public class Activator extends AbstractUIPlugin {\r
+\r
+       // The plug-in ID\r
+       public static final String PLUGIN_ID = "eu.etaxonomy.taxeditor";\r
+\r
+       // The shared instance\r
+       private static Activator plugin;\r
+       \r
+       /**\r
+        * The constructor\r
+        */\r
+       public Activator() {\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\r
+        */\r
+       public void start(BundleContext context) throws Exception {\r
+               super.start(context);\r
+               plugin = this;\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\r
+        */\r
+       public void stop(BundleContext context) throws Exception {\r
+               plugin = null;\r
+               super.stop(context);\r
+       }\r
+\r
+       /**\r
+        * Returns the shared instance\r
+        *\r
+        * @return the shared instance\r
+        */\r
+       public static Activator getDefault() {\r
+               return plugin;\r
+       }\r
+\r
+       /**\r
+        * Returns an image descriptor for the image file at the given\r
+        * plug-in relative path\r
+        *\r
+        * @param path the path\r
+        * @return the image descriptor\r
+        */\r
+       public static ImageDescriptor getImageDescriptor(String path) {\r
+               return imageDescriptorFromPlugin(PLUGIN_ID, path);\r
+       }\r
+}\r
diff --git a/src/eu/etaxonomy/taxeditor/ApplicationActionBarAdvisor.java b/src/eu/etaxonomy/taxeditor/ApplicationActionBarAdvisor.java
new file mode 100644 (file)
index 0000000..7435806
--- /dev/null
@@ -0,0 +1,91 @@
+package eu.etaxonomy.taxeditor;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.ICoolBarManager;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.action.ToolBarContributionItem;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
+import org.eclipse.ui.application.ActionBarAdvisor;
+import org.eclipse.ui.application.IActionBarConfigurer;
+
+/**
+ * An action bar advisor is responsible for creating, adding, and disposing of the
+ * actions added to a workbench window. Each window will be populated with
+ * new actions.
+ */
+public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
+
+    // Actions - important to allocate these only in makeActions, and then use them
+    // in the fill methods.  This ensures that the actions aren't recreated
+    // when fillActionBars is called with FILL_PROXY.
+    private IWorkbenchAction exitAction;
+    private IWorkbenchAction aboutAction;
+    private IWorkbenchAction newWindowAction;
+    private OpenViewAction openViewAction;
+    private Action messagePopupAction;
+    
+
+    public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
+        super(configurer);
+    }
+    
+    protected void makeActions(final IWorkbenchWindow window) {
+        // Creates the actions and registers them.
+        // Registering is needed to ensure that key bindings work.
+        // The corresponding commands keybindings are defined in the plugin.xml file.
+        // Registering also provides automatic disposal of the actions when
+        // the window is closed.
+
+        exitAction = ActionFactory.QUIT.create(window);
+        register(exitAction);
+        
+        aboutAction = ActionFactory.ABOUT.create(window);
+        register(aboutAction);
+        
+        newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window);
+        register(newWindowAction);
+        
+        openViewAction = new OpenViewAction(window, "Open Another Message View", View.ID);
+        register(openViewAction);
+        
+        messagePopupAction = new MessagePopupAction("Open Message", window);
+        register(messagePopupAction);
+    }
+    
+    protected void fillMenuBar(IMenuManager menuBar) {
+        MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);
+        MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP);
+        
+        menuBar.add(fileMenu);
+        // Add a group marker indicating where action set menus will appear.
+        menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+        menuBar.add(helpMenu);
+        
+        // File
+        fileMenu.add(newWindowAction);
+        fileMenu.add(new Separator());
+        fileMenu.add(messagePopupAction);
+        fileMenu.add(openViewAction);
+        fileMenu.add(new Separator());
+        fileMenu.add(exitAction);
+        
+        // Help
+        helpMenu.add(aboutAction);
+    }
+    
+    protected void fillCoolBar(ICoolBarManager coolBar) {
+        IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
+        coolBar.add(new ToolBarContributionItem(toolbar, "main"));   
+        toolbar.add(openViewAction);
+        toolbar.add(messagePopupAction);
+    }
+}
diff --git a/src/eu/etaxonomy/taxeditor/ApplicationWorkbenchAdvisor.java b/src/eu/etaxonomy/taxeditor/ApplicationWorkbenchAdvisor.java
new file mode 100644 (file)
index 0000000..4db1c83
--- /dev/null
@@ -0,0 +1,23 @@
+package eu.etaxonomy.taxeditor;
+
+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 {
+       
+       private static final String PERSPECTIVE_ID = "eu.etaxonomy.taxeditor.perspective";
+
+    public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
+        return new ApplicationWorkbenchWindowAdvisor(configurer);
+    }
+
+       public String getInitialWindowPerspectiveId() {
+               return PERSPECTIVE_ID;
+       } 
+       
+}
diff --git a/src/eu/etaxonomy/taxeditor/ApplicationWorkbenchWindowAdvisor.java b/src/eu/etaxonomy/taxeditor/ApplicationWorkbenchWindowAdvisor.java
new file mode 100644 (file)
index 0000000..87f6a8c
--- /dev/null
@@ -0,0 +1,26 @@
+package eu.etaxonomy.taxeditor;
+
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.application.ActionBarAdvisor;
+import org.eclipse.ui.application.IActionBarConfigurer;
+import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
+import org.eclipse.ui.application.WorkbenchWindowAdvisor;
+
+public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
+
+    public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
+        super(configurer);
+    }
+
+    public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
+        return new ApplicationActionBarAdvisor(configurer);
+    }
+    
+    public void preWindowOpen() {
+        IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
+        configurer.setInitialSize(new Point(600, 400));
+        configurer.setShowCoolBar(true);
+        configurer.setShowStatusLine(false);
+    }
+    
+}
diff --git a/src/eu/etaxonomy/taxeditor/ICommandIds.java b/src/eu/etaxonomy/taxeditor/ICommandIds.java
new file mode 100644 (file)
index 0000000..349d94c
--- /dev/null
@@ -0,0 +1,15 @@
+package eu.etaxonomy.taxeditor;
+
+/**
+ * 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 = "eu.etaxonomy.taxeditor.open";
+    public static final String CMD_OPEN_MESSAGE = "eu.etaxonomy.taxeditor.openMessage";
+    
+}
diff --git a/src/eu/etaxonomy/taxeditor/MessagePopupAction.java b/src/eu/etaxonomy/taxeditor/MessagePopupAction.java
new file mode 100644 (file)
index 0000000..f662e06
--- /dev/null
@@ -0,0 +1,25 @@
+package eu.etaxonomy.taxeditor;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.IWorkbenchWindow;
+
+
+public class MessagePopupAction extends Action {
+
+    private final IWorkbenchWindow window;
+
+    MessagePopupAction(String text, IWorkbenchWindow window) {
+        super(text);
+        this.window = window;
+        // The id is used to refer to the action in a menu or toolbar
+        setId(ICommandIds.CMD_OPEN_MESSAGE);
+        // Associate the action with a pre-defined command, to allow key bindings.
+        setActionDefinitionId(ICommandIds.CMD_OPEN_MESSAGE);
+        setImageDescriptor(eu.etaxonomy.taxeditor.Activator.getImageDescriptor("/icons/sample3.gif"));
+    }
+
+    public void run() {
+        MessageDialog.openInformation(window.getShell(), "Open", "Open Message Dialog!");
+    }
+}
\ No newline at end of file
diff --git a/src/eu/etaxonomy/taxeditor/NavigationView.java b/src/eu/etaxonomy/taxeditor/NavigationView.java
new file mode 100644 (file)
index 0000000..e4169c0
--- /dev/null
@@ -0,0 +1,151 @@
+package eu.etaxonomy.taxeditor;
+
+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 = "eu.etaxonomy.taxeditor.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
diff --git a/src/eu/etaxonomy/taxeditor/OpenViewAction.java b/src/eu/etaxonomy/taxeditor/OpenViewAction.java
new file mode 100644 (file)
index 0000000..3c617db
--- /dev/null
@@ -0,0 +1,36 @@
+package eu.etaxonomy.taxeditor;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+
+
+public class OpenViewAction extends Action {
+       
+       private final IWorkbenchWindow window;
+       private int instanceNum = 0;
+       private final String viewId;
+       
+       public OpenViewAction(IWorkbenchWindow window, String label, String viewId) {
+               this.window = window;
+               this.viewId = viewId;
+        setText(label);
+        // The id is used to refer to the action in a menu or toolbar
+               setId(ICommandIds.CMD_OPEN);
+        // Associate the action with a pre-defined command, to allow key bindings.
+               setActionDefinitionId(ICommandIds.CMD_OPEN);
+               setImageDescriptor(eu.etaxonomy.taxeditor.Activator.getImageDescriptor("/icons/sample2.gif"));
+       }
+       
+       public void run() {
+               if(window != null) {    
+                       try {
+                               window.getActivePage().showView(viewId, Integer.toString(instanceNum++), IWorkbenchPage.VIEW_ACTIVATE);
+                       } catch (PartInitException e) {
+                               MessageDialog.openError(window.getShell(), "Error", "Error opening view:" + e.getMessage());
+                       }
+               }
+       }
+}
diff --git a/src/eu/etaxonomy/taxeditor/Perspective.java b/src/eu/etaxonomy/taxeditor/Perspective.java
new file mode 100644 (file)
index 0000000..d99ea36
--- /dev/null
@@ -0,0 +1,20 @@
+package eu.etaxonomy.taxeditor;
+
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+public class Perspective implements IPerspectiveFactory {
+
+       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);
+       }
+}
diff --git a/src/eu/etaxonomy/taxeditor/TaxEditorApplication.java b/src/eu/etaxonomy/taxeditor/TaxEditorApplication.java
new file mode 100644 (file)
index 0000000..1c54913
--- /dev/null
@@ -0,0 +1,45 @@
+package eu.etaxonomy.taxeditor;
+
+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 TaxEditorApplication 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() {
+               final IWorkbench workbench = PlatformUI.getWorkbench();
+               if (workbench == null)
+                       return;
+               final Display display = workbench.getDisplay();
+               display.syncExec(new Runnable() {
+                       public void run() {
+                               if (!display.isDisposed())
+                                       workbench.close();
+                       }
+               });
+       }
+}
diff --git a/src/eu/etaxonomy/taxeditor/View.java b/src/eu/etaxonomy/taxeditor/View.java
new file mode 100644 (file)
index 0000000..20d0527
--- /dev/null
@@ -0,0 +1,77 @@
+package eu.etaxonomy.taxeditor;
+
+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 = "eu.etaxonomy.taxeditor.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 actions\n"+
+                                               "- add keybindings to actions\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() {
+       }
+}