Eclipse Intro / Welcome page
Asked Answered
U

2

5

is it possible to have links on the welcome page which point to defined commands and for example, launch an dialog?

I am thinking of having a welcome page, pointing out the steps what to do first, like:

1) change language (click here)
2) set up database connection (click here)
3) start working (click here)

"click here" should be a link to call the actual dialog to set things up. I am using Eclipse with the command style menu.

Grateful for any suggestions!

Underwater answered 18/3, 2010 at 19:46 Comment(0)
C
6

You can run jface actions from the welcome page like this (in the introContent.xml)

<link 
label="System Configuration" 
url="http://org.eclipse.ui.intro/runAction?pluginId=org.eclipse.ui.internal&#38;class=org.eclipse.ui.internal.OpenPreferencesAction">
   <img src="config.png" alt="System Configuration"/>
   <text>Current system configuration.</text>
</link>

if your intro page is in XHTML. The encoded ampersand &#38; is quite a common pitfall. You can also call your own implemented action class (not a predefined one from org.eclipse.ui.*), but you should then implement the IIntroAction like this

public class YourPreferencesAction extends OpenPreferencesAction implements IIntroAction {

    @Override
    public void run(IIntroSite site, Properties params) {
        final IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager().getIntro(); 
        PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);  
        run();
    }

}

where you close the intro page and call some method you would like to have executed, in this case run(). Your actions class should in all cases inherit from org.eclipse.jface.Action.

Caucasia answered 19/3, 2010 at 7:17 Comment(4)
Thanks, I tried the first example in root.xhtml, because in introContent.xml it wont show: <a href="org.eclipse.ui.intro/…"> <text>(try here)</text> </a> and I got a "!MESSAGE Intro tried accessing a NULL bundle."Underwater
You have to use XHTML in you introContent.xml, then it will show. It should be in a <group> tag. Like this: <page><group><link ...>Caucasia
It doesnt really matter if i put the link in introContent.xml or in root.xhtml. I tried both. Just the syntax differs the result is always the same: "!ENTRY org.eclipse.ui.intro 4 0 !MESSAGE Intro tried accessing a NULL bundle." I have the action configured and I have the right name put into the link. So what else can I do wrong?Underwater
Well, now I know. The correct link description would be: <a href="org.eclipse.ui.intro/runAction?pluginId=<our plugin name>&#38;class=<your full action class name>" id="launch"> click here for launch dialog </a>Underwater
W
1

Take a look at the Eclipse forms API. Here's a tutorial I found very useful: http://www.eclipse.org/articles/Article-Forms/article.html

Forms can have links in them, and those links call back to HyperLinkListeners. It doesn't look like the HyperLink class is linked into the Command framework yet. Though I could be wrong about that. There are a number of things that haven't really been integrated with the Command framework yet. You could use your HyperlinkListener to call the Command's handler if you like, implementing the command calling functionality manually.

Here's the API docs for HyperLinks: http://help.eclipse.org/galileo/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/forms/widgets/Hyperlink.html

Walloping answered 18/3, 2010 at 19:54 Comment(2)
In tinyurl.com/yljpb7n I found: <action name="customAction" replaces="runAction?pluginId=com.org.xyz&amp;class=com.org.xyz.CustomAction&amp;param1=value1"/> Is that what I am looking for? How would I have to implement that Action to run a command?Underwater
I don't know.. but I have a feeling that it isn't. Maybe though. I've never used the welcome page, I just thought you might be able to use the methods used in the Forms API to create a hyperlink on the welcome page. Perhaps by having your welcome page BE a form? We're going to be making a welcome page for our RCP project very soon. If I learn anything new when we tackle it I'll be sure to share.Walloping

© 2022 - 2024 — McMap. All rights reserved.