| /******************************************************************************* |
| * Copyright (c) 2004 INRIA. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * INRIA - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.m2m.atl.adt.debug; |
| |
| import java.util.MissingResourceException; |
| import java.util.ResourceBundle; |
| |
| import org.eclipse.debug.ui.DebugUITools; |
| import org.eclipse.debug.ui.IDebugModelPresentation; |
| import org.eclipse.ui.plugin.AbstractUIPlugin; |
| |
| /** |
| * The main plugin class to be used in the desktop. |
| * |
| * @author <a href="mailto:freddy.allilaire@obeo.fr">Freddy Allilaire</a> |
| * @author <a href="mailto:william.piers@obeo.fr">William Piers</a> |
| */ |
| public class AtlDebugPlugin extends AbstractUIPlugin { |
| |
| /** The shared instance. */ |
| private static AtlDebugPlugin plugin; |
| |
| IDebugModelPresentation fUtilPresentation; |
| |
| /** Resource bundle. */ |
| private ResourceBundle resourceBundle; |
| |
| /** |
| * The constructor. |
| */ |
| public AtlDebugPlugin() { |
| super(); |
| plugin = this; |
| } |
| |
| /** |
| * Returns the shared instance. |
| * |
| * @return the shared instance. |
| */ |
| public static AtlDebugPlugin getDefault() { |
| return plugin; |
| } |
| |
| /** |
| * Returns the string from the plugin's resource bundle, or 'key' if not found. |
| * |
| * @param key |
| * the default value |
| * @return the string from the plugin's resource bundle, or 'key' if not found |
| */ |
| public static String getResourceString(String key) { |
| ResourceBundle bundle = AtlDebugPlugin.getDefault().getResourceBundle(); |
| try { |
| return (bundle != null) ? bundle.getString(key) : key; |
| } catch (MissingResourceException e) { |
| return key; |
| } |
| } |
| |
| /** |
| * Returns the plugin's resource bundle. |
| * |
| * @return the plugin's resource bundle |
| */ |
| public ResourceBundle getResourceBundle() { |
| return resourceBundle; |
| } |
| |
| /** |
| * Returns the unique identifier of the plugin. |
| * |
| * @return the unique identifier of the plugin |
| */ |
| public static String getUniqueIdentifier() { |
| return AtlDebugPlugin.getDefault().getBundle().getSymbolicName(); |
| } |
| |
| /** |
| * Returns a shared utility Atl debug model presentation. Clients should not dispose the presentation. |
| * |
| * @return an Atl debug model presentation |
| */ |
| public IDebugModelPresentation getModelPresentation() { |
| if (fUtilPresentation == null) { |
| fUtilPresentation = DebugUITools.newDebugModelPresentation(getUniqueIdentifier()); |
| } |
| return fUtilPresentation; |
| } |
| } |