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: package org.apache.axis2.tool.service.eclipse.plugin;
020:
021: import org.eclipse.jface.resource.ImageDescriptor;
022: import org.eclipse.ui.plugin.AbstractUIPlugin;
023: import org.osgi.framework.BundleContext;
024:
025: import java.util.MissingResourceException;
026: import java.util.ResourceBundle;
027:
028: /**
029: * The main plugin class to be used in the desktop.
030: */
031: public class ServiceArchiver extends AbstractUIPlugin {
032: //The shared instance.
033: private static ServiceArchiver plugin;
034: //Resource bundle.
035: private ResourceBundle resourceBundle;
036: private static ImageDescriptor wizardImageDescriptor;
037:
038: /**
039: * The constructor.
040: */
041: public ServiceArchiver() {
042: super ();
043: plugin = this ;
044: try {
045: resourceBundle = ResourceBundle
046: .getBundle("org.apache.axis2.tool.service.resource.ServiceResources");
047: } catch (MissingResourceException x) {
048: resourceBundle = null;
049: }
050: }
051:
052: /**
053: * This method is called upon plug-in activation
054: */
055: public void start(BundleContext context) throws Exception {
056: super .start(context);
057: }
058:
059: /**
060: * This method is called when the plug-in is stopped
061: */
062: public void stop(BundleContext context) throws Exception {
063: super .stop(context);
064: }
065:
066: /**
067: * Returns the shared instance.
068: */
069: public static ServiceArchiver getDefault() {
070: return plugin;
071: }
072:
073: /**
074: * Returns the string from the plugin's resource bundle,
075: * or 'key' if not found.
076: */
077: public static String getResourceString(String key) {
078: ResourceBundle bundle = ServiceArchiver.getDefault()
079: .getResourceBundle();
080: try {
081: return (bundle != null) ? bundle.getString(key) : key;
082: } catch (MissingResourceException e) {
083: return key;
084: }
085: }
086:
087: /**
088: * Returns the plugin's resource bundle,
089: */
090: public ResourceBundle getResourceBundle() {
091: return resourceBundle;
092: }
093:
094: public static ImageDescriptor getWizardImageDescriptor() {
095: if (wizardImageDescriptor == null) {
096: wizardImageDescriptor = ServiceArchiver
097: .imageDescriptorFromPlugin("Axis_Service_Archiver",
098: "icons/asf-feather.gif");
099: }
100: return wizardImageDescriptor;
101: }
102: }
|