Changeset 3469


Ignore:
Timestamp:
Mar 8, 2008, 7:28:09 PM (13 years ago)
Author:
yura
Message:
  • Simplification
Location:
devel-tools/trunk/eclipse/org.refal.plus.rfpdt.launch/src/org/refal/plus/rfpdt/launch
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt.launch/src/org/refal/plus/rfpdt/launch/LaunchingPlugin.java

    r3449 r3469  
    11package org.refal.plus.rfpdt.launch;
    2 
    3 import java.util.MissingResourceException;
    4 import java.util.ResourceBundle;
    52
    63import org.eclipse.swt.widgets.Shell;
     
    85import org.eclipse.ui.IWorkbenchWindow;
    96import org.eclipse.ui.plugin.AbstractUIPlugin;
    10 import org.osgi.framework.BundleContext;
    117
    128public class LaunchingPlugin extends AbstractUIPlugin {
    13     // The shared instance.
    149    private static LaunchingPlugin plugin;
    1510
    16     private ResourceBundle resourceBundle;
    17 
    18     public LaunchingPlugin () {
    19         super();
    20         plugin = this;
    21         try {
    22             resourceBundle = ResourceBundle.getBundle("org.refal.plus.rfpdt.launch.LaunchingPluginResources");
    23         } catch (MissingResourceException x) {
    24             resourceBundle = null;
    25         }
    26     }
    27 
    28     /**
    29      * This method is called upon plug-in activation
    30      */
    31     public void start (BundleContext context) throws Exception {
    32         super.start(context);
    33     }
    34 
    35     /**
    36      * This method is called when the plug-in is stopped
    37      */
    38     public void stop (BundleContext context) throws Exception {
    39         super.stop(context);
    40     }
    41 
    42     /**
    43      * Returns the shared instance.
    44      */
    45     public static LaunchingPlugin getDefault () {
    46         return plugin;
    47     }
    48 
    49     /**
    50      * Returns the string from the plugin's resource bundle, or 'key' if not found.
    51      */
    52     public static String getResourceString (String key) {
    53         ResourceBundle bundle = LaunchingPlugin.getDefault().getResourceBundle();
    54         try {
    55             return (bundle != null) ? bundle.getString(key) : key;
    56         } catch (MissingResourceException e) {
    57             return key;
    58         }
    59     }
    60 
    61     /**
    62      * Returns the plugin's resource bundle,
    63      */
    64     public ResourceBundle getResourceBundle () {
    65         return resourceBundle;
     11    private static IWorkbenchWindow getActiveWorkbenchWindow () {
     12        return plugin == null ? null : plugin.getWorkbench().getActiveWorkbenchWindow();
    6613    }
    6714
     
    7118    public static Shell getShell () {
    7219        IWorkbenchWindow window = getActiveWorkbenchWindow();
    73         if (window != null) {
    74             return window.getShell();
    75         }
    76         return null;
    77     }
    78 
    79     public static IWorkbenchWindow getActiveWorkbenchWindow () {
    80         return getDefault().getWorkbench().getActiveWorkbenchWindow();
     20        return window == null ? null : window.getShell();
    8121    }
    8222
    8323    public static IWorkbenchPage getActivePage () {
    84         IWorkbenchWindow w = getActiveWorkbenchWindow();
    85         if (w != null) {
    86             return w.getActivePage();
    87         }
    88         return null;
     24        IWorkbenchWindow window = getActiveWorkbenchWindow();
     25        return window == null ? null : window.getActivePage();
     26    }
     27
     28    public LaunchingPlugin () {
     29        super();
     30        plugin = this;
    8931    }
    9032}
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt.launch/src/org/refal/plus/rfpdt/launch/ui/RfpLaunchShortcut.java

    r3468 r3469  
    2424import org.eclipse.ui.IWorkbenchPage;
    2525import org.eclipse.ui.dialogs.ElementListSelectionDialog;
     26import org.refal.plus.rfpdt.core.builder.RfpBuilder;
    2627import org.refal.plus.rfpdt.editor.RfpEditor;
    2728import org.refal.plus.rfpdt.launch.IRfpLaunchConfigurationConstants;
     
    5758    }
    5859
    59     static void createConfiguration (ILaunchConfigurationWorkingCopy config) {
     60    public static void createConfiguration (ILaunchConfigurationWorkingCopy config) {
    6061        createConfiguration(config, getResource());
    6162    }
     
    8182    private static String getWorkingDirectory (IFile module) {
    8283        return module.getParent().getFullPath().makeRelative().toString();
    83     }
    84 
    85     private static String getModuleName (IFile module) {
    86         return module.getProjectRelativePath().removeFileExtension().toString().replace('/', '.');
    8784    }
    8885
     
    10097            for (ILaunchConfiguration config : configs)
    10198                if (config.getAttribute(IRfpLaunchConfigurationConstants.ATTR_MODULE_NAME, "").equals(
    102                         getModuleName(module))
     99                        RfpBuilder.getModuleName(module))
    103100                        && config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, "").equals(
    104101                                getWorkingDirectory(module)))
     
    189186        if (module != null) {
    190187            config.setAttribute(IRfpLaunchConfigurationConstants.ATTR_PROJECT_NAME, module.getProject().getName());
    191             config.setAttribute(IRfpLaunchConfigurationConstants.ATTR_MODULE_NAME, getModuleName(module));
     188            config.setAttribute(IRfpLaunchConfigurationConstants.ATTR_MODULE_NAME, RfpBuilder.getModuleName(module));
    192189            config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, getWorkingDirectory(module));
    193190        }
Note: See TracChangeset for help on using the changeset viewer.