Search in sources :

Example 1 with DerbyPlugin

use of org.apache.derby.ui.DerbyPlugin in project derby by apache.

the class DerbyUtils method launch.

// another launch mechanism
public void launch() throws CoreException {
    DerbyPlugin plugin = DerbyPlugin.getDefault();
    // constructs a classpath from the default JRE...
    IPath systemLibs = new Path(JavaRuntime.JRE_CONTAINER);
    IRuntimeClasspathEntry systemLibsEntry = JavaRuntime.newRuntimeContainerClasspathEntry(systemLibs, IRuntimeClasspathEntry.STANDARD_CLASSES);
    systemLibsEntry.setClasspathProperty(IRuntimeClasspathEntry.BOOTSTRAP_CLASSES);
    // include org.apache.derby.core plugin
    IRuntimeClasspathEntry derbyCPEntry = null;
    List classpath = new ArrayList();
    classpath.add(systemLibsEntry.getMemento());
    try {
        ManifestElement[] elements_core, elements_ui;
        elements_core = getElements(CommonNames.CORE_PATH);
        elements_ui = getElements(CommonNames.UI_PATH);
        Bundle bundle;
        URL pluginURL, jarURL, localURL;
        bundle = Platform.getBundle(CommonNames.CORE_PATH);
        pluginURL = bundle.getEntry("/");
        for (int i = 0; i < elements_core.length; i++) {
            if (!elements_core[i].getValue().toLowerCase().endsWith("derbynet.jar")) {
                jarURL = new URL(pluginURL, elements_core[i].getValue());
                localURL = Platform.asLocalURL(jarURL);
                derbyCPEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(localURL.getPath()));
                derbyCPEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
                classpath.add(derbyCPEntry.getMemento());
            }
        }
        bundle = Platform.getBundle(CommonNames.CORE_PATH);
        pluginURL = bundle.getEntry("/");
        for (int i = 0; i < elements_ui.length; i++) {
            if (!elements_ui[i].getValue().toLowerCase().equals("ui.jar")) {
                jarURL = new URL(pluginURL, elements_ui[i].getValue());
                localURL = Platform.asLocalURL(jarURL);
                derbyCPEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(localURL.getPath()));
                derbyCPEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
                classpath.add(derbyCPEntry.getMemento());
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        Logger.log("Error in launch() " + e, IStatus.ERROR);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ManifestElement(org.eclipse.osgi.util.ManifestElement) IPath(org.eclipse.core.runtime.IPath) Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IRuntimeClasspathEntry(org.eclipse.jdt.launching.IRuntimeClasspathEntry) URL(java.net.URL) CoreException(org.eclipse.core.runtime.CoreException) BundleException(org.osgi.framework.BundleException) DerbyPlugin(org.apache.derby.ui.DerbyPlugin)

Example 2 with DerbyPlugin

use of org.apache.derby.ui.DerbyPlugin in project derby by apache.

the class IJAction method run.

/**
 * @see IActionDelegate#run(IAction)
 */
public void run(IAction action) {
    Shell shell = new Shell();
    DerbyPlugin plugin = DerbyPlugin.getDefault();
    if (plugin == null) {
        MessageDialog.openInformation(shell, CommonNames.PLUGIN_NAME, Messages.NO_ACTION);
    } else {
        try {
            if (currentJavaProject != null) {
                currentProject = currentJavaProject.getProject();
            }
            if (currentProject.isNatureEnabled(CommonNames.DERBY_NATURE)) {
                DerbyUtils.runIJ(currentScript, currentProject);
            } else {
                shell = new Shell();
                MessageDialog.openInformation(shell, CommonNames.PLUGIN_NAME, Messages.NO_DERBY_NATURE + "\n" + Messages.ADD_N_TRY);
            }
        } catch (Exception e) {
            Logger.log("IAction.run() error " + e, IStatus.ERROR);
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) DerbyPlugin(org.apache.derby.ui.DerbyPlugin)

Example 3 with DerbyPlugin

use of org.apache.derby.ui.DerbyPlugin in project derby by apache.

the class SysInfoAction method run.

/**
 * @see IActionDelegate#run(IAction)
 */
public void run(IAction action) {
    Shell shell = new Shell();
    DerbyPlugin plugin = DerbyPlugin.getDefault();
    if (plugin == null) {
        MessageDialog.openInformation(shell, CommonNames.PLUGIN_NAME, Messages.NO_ACTION);
    } else {
        try {
            if (currentJavaProject != null) {
                DerbyUtils.runSysInfo(currentJavaProject.getProject());
            } else {
                DerbyUtils.runSysInfo(currentProject);
            }
        } catch (CoreException ce) {
            ce.printStackTrace(System.err);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) CoreException(org.eclipse.core.runtime.CoreException) CoreException(org.eclipse.core.runtime.CoreException) DerbyPlugin(org.apache.derby.ui.DerbyPlugin)

Aggregations

DerbyPlugin (org.apache.derby.ui.DerbyPlugin)3 CoreException (org.eclipse.core.runtime.CoreException)2 Shell (org.eclipse.swt.widgets.Shell)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 IRuntimeClasspathEntry (org.eclipse.jdt.launching.IRuntimeClasspathEntry)1 ManifestElement (org.eclipse.osgi.util.ManifestElement)1 Bundle (org.osgi.framework.Bundle)1 BundleException (org.osgi.framework.BundleException)1