01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: ******************************************************************************/package org.eclipse.ui.examples.contributions;
11:
12: import java.util.ArrayList;
13: import java.util.List;
14:
15: import org.eclipse.jface.resource.ImageDescriptor;
16: import org.eclipse.ui.examples.contributions.model.Person;
17: import org.eclipse.ui.plugin.AbstractUIPlugin;
18: import org.osgi.framework.BundleContext;
19:
20: /**
21: * The activator class controls the plug-in life cycle.
22: *
23: * @since 3.3
24: */
25: public class Activator extends AbstractUIPlugin {
26:
27: // The plug-in ID
28: public static final String PLUGIN_ID = "org.eclipse.ui.examples.contributions"; //$NON-NLS-1$
29:
30: // The shared instance
31: private static Activator plugin;
32:
33: /**
34: * The constructor
35: */
36: public Activator() {
37: }
38:
39: /*
40: * (non-Javadoc)
41: * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
42: */
43: public void start(BundleContext context) throws Exception {
44: super .start(context);
45: plugin = this ;
46: }
47:
48: /*
49: * (non-Javadoc)
50: * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
51: */
52: public void stop(BundleContext context) throws Exception {
53: plugin = null;
54: super .stop(context);
55: }
56:
57: /**
58: * Returns the shared instance
59: *
60: * @return the shared instance
61: */
62: public static Activator getDefault() {
63: return plugin;
64: }
65:
66: /**
67: * Returns an image descriptor for the image file at the given
68: * plug-in relative path
69: *
70: * @param path the path
71: * @return the image descriptor
72: */
73: public static ImageDescriptor getImageDescriptor(String path) {
74: return imageDescriptorFromPlugin(PLUGIN_ID, path);
75: }
76:
77: private static List model = null;
78:
79: public static List getModel() {
80: if (model == null) {
81: model = new ArrayList();
82: model.add(new Person("Doe", "John")); //$NON-NLS-1$//$NON-NLS-2$
83: model.add(new Person("Doe", "Jane")); //$NON-NLS-1$//$NON-NLS-2$
84: model.add(new Person("Public", "John")); //$NON-NLS-1$//$NON-NLS-2$
85: model.add(new Person("Public", "Jane")); //$NON-NLS-1$//$NON-NLS-2$
86: }
87: return model;
88: }
89: }
|