001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019:
020: package org.apache.axis2.tool.codegen.eclipse.plugin;
021:
022: import org.eclipse.jface.resource.ImageDescriptor;
023: import org.eclipse.ui.plugin.AbstractUIPlugin;
024: import org.osgi.framework.BundleContext;
025:
026: import java.util.MissingResourceException;
027: import java.util.ResourceBundle;
028:
029: /**
030: * The main plugin class to be used in the desktop.
031: */
032: public class CodegenWizardPlugin extends AbstractUIPlugin {
033: //The shared instance.
034: private static CodegenWizardPlugin plugin;
035: //Resource bundle.
036: private ResourceBundle resourceBundle;
037: private static ImageDescriptor wizardImageDescriptor;
038:
039: /**
040: * The constructor.
041: */
042: public CodegenWizardPlugin() {
043: super ();
044: plugin = this ;
045: try {
046: resourceBundle = ResourceBundle
047: .getBundle("org.apache.axis2.tool.codegen.resource.Codegen");
048: } catch (MissingResourceException x) {
049: resourceBundle = null;
050: }
051: }
052:
053: /**
054: * This method is called upon plug-in activation
055: */
056: public void start(BundleContext context) throws Exception {
057: super .start(context);
058: }
059:
060: /**
061: * This method is called when the plug-in is stopped
062: */
063: public void stop(BundleContext context) throws Exception {
064: super .stop(context);
065: }
066:
067: /**
068: * Returns the shared instance.
069: */
070: public static CodegenWizardPlugin getDefault() {
071: return plugin;
072: }
073:
074: /**
075: * Returns the string from the plugin's resource bundle,
076: * or 'key' if not found.
077: */
078: public static String getResourceString(String key) {
079: ResourceBundle bundle = CodegenWizardPlugin.getDefault()
080: .getResourceBundle();
081: try {
082: return (bundle != null) ? bundle.getString(key) : key;
083: } catch (MissingResourceException e) {
084: return key;
085: }
086: }
087:
088: /**
089: * Returns the plugin's resource bundle,
090: */
091: public ResourceBundle getResourceBundle() {
092: return resourceBundle;
093: }
094:
095: public static ImageDescriptor getWizardImageDescriptor() {
096: if (wizardImageDescriptor == null) {
097: wizardImageDescriptor = CodegenWizardPlugin
098: .imageDescriptorFromPlugin("Axis2_Codegen_Wizard",
099: "icons/asf-feather.gif");
100: }
101: return wizardImageDescriptor;
102: }
103:
104: }
|