Missing ResourceBundle in my created plugin [message #275664] |
Wed, 10 November 2004 13:50  |
Eclipse User |
|
|
|
Originally posted by: un_owen.hotmail.com
I'm creating a simple text editor with my own custom Content Assist. The
editor plugin won't start with the Content Assist, but will work fine
without the Content Assist. I've managed to figure out that the
ResourceBundle is null when the editor createsActions. Does anyone know what
I'm doing wrong here?
Thanks
Stephen Tse
package bshEditor.editor;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.texteditor.ContentAssistAction;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import java.util.ResourceBundle;
import bshEditor.BshEditorPlugin;
public class BshEditor extends TextEditor
{
private ResourceBundle resourceBundle;
public BshEditor ()
{
super ();
resourceBundle = BshEditorPlugin.getDefault ().getResourceBundle ();
}
protected void createActions ()
{
super.createActions();
resourceBundle = BshEditorPlugin.getDefault ().getResourceBundle (); <====
this is null
ContentAssistAction action =
new ContentAssistAction (resourceBundle, "ContentAssistProposal.", this);
<=== crashes here
action.setActionDefinitionId (
ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
setAction("ContentAssistProposal", action);
}
}
package bshEditor;
import org.eclipse.ui.plugin.*;
import org.osgi.framework.BundleContext;
import java.util.*;
/**
* The main plugin class to be used in the desktop.
*/
public class BshEditorPlugin extends AbstractUIPlugin {
//The shared instance.
private static BshEditorPlugin plugin;
//Resource bundle.
private ResourceBundle resourceBundle;
/**
* The constructor.
*/
public BshEditorPlugin() {
super();
plugin = this;
try {
resourceBundle =
ResourceBundle.getBundle("bshEditor.BshEditorPluginResources ");
} catch (MissingResourceException x) {
resourceBundle = null;
}
}
public void start(BundleContext context) throws Exception {
super.start(context);
}
public void stop(BundleContext context) throws Exception {
super.stop(context);
}
public static BshEditorPlugin getDefault() {
return plugin;
}
public static String getResourceString(String key) {
ResourceBundle bundle = BshEditorPlugin.getDefault().getResourceBundle();
try {
return (bundle != null) ? bundle.getString(key) : key;
} catch (MissingResourceException e) {
return key;
}
}
public ResourceBundle getResourceBundle() {
return resourceBundle;
}
}
|
|
|
Re: Missing ResourceBundle in my created plugin [message #275680 is a reply to message #275664] |
Wed, 10 November 2004 20:13  |
Eclipse User |
|
|
|
Originally posted by: Chris_Laffra.ca.ibm.com
Set a couple of breakpoints and step through your code using the debugger.
Observe the variables. See when they get initialized (if at all).
Chris
"Stephen Tse" <un_owen@hotmail.com> wrote in message
news:cmtnt4$jcf$1@eclipse.org...
> I'm creating a simple text editor with my own custom Content Assist. The
> editor plugin won't start with the Content Assist, but will work fine
> without the Content Assist. I've managed to figure out that the
> ResourceBundle is null when the editor createsActions. Does anyone know
what
> I'm doing wrong here?
>
> Thanks
> Stephen Tse
>
> package bshEditor.editor;
>
> import org.eclipse.ui.editors.text.TextEditor;
> import org.eclipse.ui.texteditor.ContentAssistAction;
> import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
>
> import java.util.ResourceBundle;
> import bshEditor.BshEditorPlugin;
>
> public class BshEditor extends TextEditor
> {
> private ResourceBundle resourceBundle;
>
> public BshEditor ()
> {
> super ();
> resourceBundle = BshEditorPlugin.getDefault ().getResourceBundle ();
> }
>
> protected void createActions ()
> {
> super.createActions();
>
> resourceBundle = BshEditorPlugin.getDefault ().getResourceBundle ();
<====
> this is null
>
> ContentAssistAction action =
> new ContentAssistAction (resourceBundle, "ContentAssistProposal.",
this);
> <=== crashes here
>
> action.setActionDefinitionId (
> ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
> setAction("ContentAssistProposal", action);
> }
> }
>
>
>
> package bshEditor;
>
> import org.eclipse.ui.plugin.*;
> import org.osgi.framework.BundleContext;
> import java.util.*;
>
> /**
> * The main plugin class to be used in the desktop.
> */
> public class BshEditorPlugin extends AbstractUIPlugin {
> //The shared instance.
> private static BshEditorPlugin plugin;
> //Resource bundle.
> private ResourceBundle resourceBundle;
>
> /**
> * The constructor.
> */
> public BshEditorPlugin() {
> super();
> plugin = this;
> try {
> resourceBundle =
> ResourceBundle.getBundle("bshEditor.BshEditorPluginResources ");
> } catch (MissingResourceException x) {
> resourceBundle = null;
> }
> }
>
> public void start(BundleContext context) throws Exception {
> super.start(context);
> }
>
> public void stop(BundleContext context) throws Exception {
> super.stop(context);
> }
>
> public static BshEditorPlugin getDefault() {
> return plugin;
> }
>
> public static String getResourceString(String key) {
> ResourceBundle bundle =
BshEditorPlugin.getDefault().getResourceBundle();
> try {
> return (bundle != null) ? bundle.getString(key) : key;
> } catch (MissingResourceException e) {
> return key;
> }
> }
>
> public ResourceBundle getResourceBundle() {
> return resourceBundle;
> }
> }
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03650 seconds