Changeset 3500


Ignore:
Timestamp:
Mar 12, 2008, 6:15:08 PM (13 years ago)
Author:
yura
Message:
  • Java Nature.
Location:
devel-tools/trunk/eclipse
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt.ui/META-INF/MANIFEST.MF

    r3496 r3500  
    1919 org.eclipse.jdt.debug.ui,
    2020 org.eclipse.jdt.launching,
    21  org.refal.plus.rfpdt
     21 org.refal.plus.rfpdt,
     22 org.eclipse.jdt.core
    2223Eclipse-LazyStart: true
    2324Bundle-RequiredExecutionEnvironment: J2SE-1.5
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt.ui/src/org/refal/plus/rfpdt/launch/ui/RfpLaunchShortcut.java

    r3498 r3500  
    189189            config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, getWorkingDirectory(module));
    190190        }
    191         config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
    192                 IRfpLaunchConfigurationConstants.CLASSPATH_PROVIDER);
    193         config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER,
    194                 IRfpLaunchConfigurationConstants.CLASSPATH_PROVIDER);
    195191    }
    196192
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt.ui/src/org/refal/plus/rfpdt/ui/wizards/RfpProjectCreationOperation.java

    r3444 r3500  
    22
    33import org.eclipse.core.runtime.Preferences;
     4import org.eclipse.jdt.core.JavaCore;
    45import org.refal.plus.rfpdt.core.ICorePreferenceNames;
    56import org.refal.plus.rfpdt.core.RfpCorePlugin;
     
    2021        @Override
    2122        protected String[] getProjectNatures() {
    22                 return new String[] { RfpNature.NATURE_ID };
     23                return new String[] { RfpNature.NATURE_ID, JavaCore.NATURE_ID };
    2324        }
    2425
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt/src/org/refal/plus/rfpdt/core/RfpCorePlugin.java

    r3492 r3500  
    11package org.refal.plus.rfpdt.core;
    22
     3import java.util.HashMap;
     4import java.util.Map;
     5
     6import org.eclipse.core.resources.IProject;
     7import org.eclipse.core.runtime.CoreException;
    38import org.eclipse.core.runtime.IStatus;
    49import org.eclipse.core.runtime.Platform;
    510import org.eclipse.core.runtime.Plugin;
    611import org.eclipse.core.runtime.Status;
     12import org.eclipse.jdt.core.IJavaProject;
     13import org.eclipse.jdt.core.JavaCore;
    714import org.osgi.framework.BundleContext;
     15import org.refal.plus.rfpdt.core.builder.RfpNature;
    816
    917/**
     
    1220public class RfpCorePlugin extends Plugin {
    1321
    14         public static final String PLUGIN_ID = "org.refal.plus.rfpdt";
     22    public static final String PLUGIN_ID = "org.refal.plus.rfpdt";
    1523
    16         private static RfpCorePlugin plugin;
     24    private static RfpCorePlugin plugin;
    1725
    18         public RfpCorePlugin() {
    19                 plugin = this;
    20         }
     26    public RfpCorePlugin () {
     27        plugin = this;
     28    }
    2129
    22         /*
    23          * (non-Javadoc)
    24          * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
    25          */
    26         public void start(BundleContext context) throws Exception {
    27                 super.start(context);
    28         }
     30    /*
     31     * (non-Javadoc)
     32     *
     33     * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
     34     */
     35    public void start (BundleContext context) throws Exception {
     36        super.start(context);
     37    }
    2938
    30         /*
    31          * (non-Javadoc)
    32          * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
    33          */
    34         public void stop(BundleContext context) throws Exception {
    35                 plugin = null;
    36                 super.stop(context);
    37         }
     39    /*
     40     * (non-Javadoc)
     41     *
     42     * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
     43     */
     44    public void stop (BundleContext context) throws Exception {
     45        plugin = null;
     46        super.stop(context);
     47    }
    3848
    39         /**
    40         * Returns the shared instance
    41          *
    42         * @return the shared instance
    43         */
    44         public static RfpCorePlugin getDefault() {
    45                 return plugin;
    46         }
     49    /**
     50    * Returns the shared instance
     51     *
     52    * @return the shared instance
     53    */
     54    public static RfpCorePlugin getDefault () {
     55        return plugin;
     56    }
    4757
     58    public static String getPluginId () {
     59        return getDefault().getBundle().getSymbolicName();
     60    }
    4861
    49         public static String getPluginId() {
    50                 return getDefault().getBundle().getSymbolicName();
    51         }
     62    // logging and tracing
     63    // ////////////////////
    5264
    53         // logging and tracing
    54         // ////////////////////
     65    /**
     66     * Logs a message to the plugin's error log
     67     *
     68     * @param message
     69     *            Message to be logger
     70     * @param severity
     71     *            One of IStatus.ERROR, IStatus.CANCEL, IStatus.INFO, IStatus.OK or IStatus.WARNING
     72     */
     73    public static void log (final String message, final int severity) {
     74        String id = getPluginId();
     75        Status status = new Status(severity, id, IStatus.OK, message, null);
     76        getDefault().getLog().log(status);
     77    }
    5578
    56         /**
    57          * Logs a message to the plugin's error log
    58          *
    59          * @param message       Message to be logger
    60          * @param severity      One of IStatus.ERROR, IStatus.CANCEL, IStatus.INFO,
    61          *                                      IStatus.OK or IStatus.WARNING
    62          */
    63         public static void log(final String message, final int severity) {
    64                 String id = getPluginId();
    65                 Status status = new Status(severity, id, IStatus.OK, message, null);
    66                 getDefault().getLog().log(status);
    67         }
     79    public static void log (final String message, final Throwable thr) {
     80        String id = getPluginId();
     81        Status status = new Status(IStatus.ERROR, id, IStatus.OK, message, thr);
     82        getDefault().getLog().log(status);
     83    }
    6884
    69         public static void log(final String message, final Throwable thr) {
    70                 String id = getPluginId();
    71                 Status status = new Status(IStatus.ERROR, id, IStatus.OK, message, thr);
    72                 getDefault().getLog().log(status);
    73         }
     85    public static boolean isTracing (final String optionId) {
     86        String option = getPluginId() + "/trace/" + optionId;
     87        String value = Platform.getDebugOption(option);
     88        return value != null && value.equals("true");
     89    }
    7490
    75         public static boolean isTracing(final String optionId) {
    76                 String option = getPluginId() + "/trace/" + optionId;
    77                 String value = Platform.getDebugOption(option);
    78                 return value != null && value.equals("true");
    79         }
     91    public static void log (final IStatus status) {
     92        getDefault().getLog().log(status);
     93    }
    8094
    81         public static void log(final IStatus status) {
    82                 getDefault().getLog().log(status);
    83         }
     95    public static void log (Throwable e) {
     96        log(new Status(IStatus.ERROR, getPluginId(), IStatus.OK, "Internal error", e));
     97    }
    8498
    85         public static void log(Throwable e) {
    86                 log(new Status(IStatus.ERROR, getPluginId(), IStatus.OK, "Internal error", e));
    87         }
     99    private static final Map<IProject, IJavaProject> javaProjects = new HashMap<IProject, IJavaProject>();
     100
     101    public static IJavaProject getJavaProject (IProject project) {
     102        try {
     103            if (project == null || !project.exists() || !project.hasNature(RfpNature.NATURE_ID))
     104                return null;
     105        } catch (CoreException e) {
     106            log(e);
     107            return null;
     108        }
     109        IJavaProject p = (IJavaProject) javaProjects.get(project);
     110        if (p == null) {
     111            p = JavaCore.create(project);
     112            javaProjects.put(project, p);
     113        }
     114        return p;
     115    }
    88116}
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt/src/org/refal/plus/rfpdt/core/builder/RfpNature.java

    r3444 r3500  
    66import org.eclipse.core.resources.IProjectNature;
    77import org.eclipse.core.runtime.CoreException;
     8import org.eclipse.core.runtime.Path;
     9import org.eclipse.jdt.core.IClasspathEntry;
     10import org.eclipse.jdt.core.IJavaProject;
     11import org.eclipse.jdt.core.JavaCore;
     12import org.eclipse.jdt.launching.JavaRuntime;
     13import org.refal.plus.rfpdt.core.RfpCorePlugin;
     14import org.refal.plus.rfpdt.launching.RfpContainerInitializerAndResolver;
    815
    916public class RfpNature implements IProjectNature {
     
    2532        desc.setBuildSpec(newCommands);
    2633        project.setDescription(desc, null);
     34
     35        { // setup the .classpath
     36            IJavaProject javaProject = RfpCorePlugin.getJavaProject(project);
     37            IClasspathEntry[] entriesOld = javaProject.getRawClasspath();
     38            IClasspathEntry[] entriesNew = new IClasspathEntry[entriesOld.length + 2];
     39            System.arraycopy(entriesOld, 0, entriesNew, 0, entriesOld.length);
     40            // for (int i = 0; i < entriesOld.length; i++)
     41            // if (entriesOld[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) {
     42            // IFolder src = project.getFolder("src");
     43            // if (!src.exists())
     44            // src.create(true, true, null);
     45            // entriesNew[i] = JavaCore.newSourceEntry(src.getFullPath());
     46            //                }
     47            entriesNew[entriesOld.length + 0] = JavaCore.newContainerEntry(new Path(
     48                    RfpContainerInitializerAndResolver.RFP_CONTAINER));
     49            entriesNew[entriesOld.length + 1] = JavaCore.newContainerEntry(new Path(JavaRuntime.JRE_CONTAINER));
     50            javaProject.setRawClasspath(entriesNew, null);
     51            javaProject.save(null, true);
     52        }
    2753    }
    2854
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt/src/org/refal/plus/rfpdt/launching/IRfpLaunchConfigurationConstants.java

    r3499 r3500  
    88 */
    99public interface IRfpLaunchConfigurationConstants /* extends IJavaLaunchConfigurationConstants */{
    10     public static final String ATTR_PROJECT_NAME = "org.refal.plus.rfpdt.launch.project_name"; // FIXME: Project is not JavaProject, must be IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME
     10    public static final String ATTR_PROJECT_NAME = IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME;
    1111    public static final String ATTR_MODULE_NAME = IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME;
    1212    public static final String PLUGIN_ID = "org.refal.plus.rfpdt.launch";
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt/src/org/refal/plus/rfpdt/launching/RfpContainerInitializerAndResolver.java

    r3499 r3500  
    3030        private RfpContainer (IPath containerPath) {
    3131            this.containerPath = containerPath;
    32             IPath path = getPath();
     32            IPath path = RfpContainerInitializerAndResolver.getPath();
    3333            this.entries = path == null ? new IClasspathEntry[0] : new IClasspathEntry[] { JavaCore.newLibraryEntry(
    3434                    path, null, null) };
Note: See TracChangeset for help on using the changeset viewer.