Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sapphire » Extending Sapphire Wizards(Extending Sapphire Wizards)
Extending Sapphire Wizards [message #721415] Thu, 01 September 2011 13:33 Go to next message
Kamesh Sampath is currently offline Kamesh Sampath
Messages: 213
Registered: July 2009
Senior Member
I am trying to extend the Sapphire Wizards, the idea is that I need to add few pages from the JDT.ui plugin e.g. NewInterfaceWizardPage and then allow Sapphire to pick the pages from the sdef.

I also need to do declarative def of the wizard in the plugin.xml .

When I do it i see the Wizard in the respective category but when start the wizard i get the folling error

Quote:
The selected wizard could not be started.
Plug-in "com.sk.contentassist.demo" was unable to instantiate class "org.eclipse.sapphire.ui.wizards.NewSapphireModelCreationWizard".
org.eclipse.sapphire.ui.wizards.NewSapphireModelCreationWizard


I dont see any .log files to see the detailed traces or my console showing the errors Sad

Base model class:


@GenerateImpl
@XmlRootBinding(elementName = "sapphire-model")
public interface ISapphireModelDef extends IExecutableModelElement {

    ModelElementType TYPE = new ModelElementType(ISapphireModelDef.class);

    // *** ValueProperties ***

    @Type(base = ISModelValueProperty.class)
    @Label(standard = "Value Properties")
    @XmlListBinding(mappings = { @XmlListBinding.Mapping(element = "", type = ISModelTypedValueProperty.class) })
    ListProperty PROP_VALUE_PROPERTIES = new ListProperty(TYPE,
            "ValueProperties");

    ModelElementList<ISModelValueProperty> getValueProperties();

    // *** Method: execute ***

    @DelegateImplementation(ISapphireModelDefOpMethods.class)
    Status execute(ProgressMonitor monitor);

}



Wizard Classes

public abstract class NewElementWizard<M extends IExecutableModelElement>
        extends SapphireWizard<M> {

    public NewElementWizard(M modelElement, String wizardDefPath) {
        super(modelElement, wizardDefPath);
        setNeedsProgressMonitor(true);
    }

    public abstract void addCustomPages();

}

public class NewSapphireModelCreationWizard extends
        NewElementWizard<ISapphireModelDef> {

    public final static String ID = "org.eclipse.sapphire.ui.wizards.NewSapphireModelCreationWizard";
    private final static String WIZARD_DEF_PATH = "com.sk.contentassist.demo/org/eclipse/sapphire/ui/wizards/sapphire-model-wizards.sdef!new.sapphire.model.creation.wizard";

    private NewInterfaceWizardPage modelElementClass;

    /**
     * @param modelElement
     * @param wizardDefPath
     */
    public NewSapphireModelCreationWizard(ISapphireModelDef modelElement,
            String wizardDefPath) {
        super(modelElement, NewSapphireModelCreationWizard.WIZARD_DEF_PATH);
        addCustomPages();
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.eclipse.sapphire.ui.wizards.NewElementWizard#addCustomPages()
     */
    @Override
    public void addCustomPages() {
        if (this.modelElementClass == null) {
            this.modelElementClass = new NewInterfaceWizardPage();
            super.addPage(modelElementClass);
        }

    }

}


sdef
<definition>
    <import>
        <package>org.eclipse.sapphire.model</package>
    </import>
    <wizard>
        <id>new.sapphire.model.creation.wizard</id>
        <label>New Sapphire Model</label>
        <description>This wizard will allow the creation of New Sapphire Models</description>
        <image>icons/sapphire-32.png</image>
        <page>
            <id>new-sapphire-model.valueproperties.page</id>
            <label>Value Properties</label>
            <description>Define all value properties for the model</description>
            <content>
                <property-editor>ValueProperties</property-editor>
            </content>
        </page>
    </wizard>
</definition>


finally my plugin.xml

<plugin>
   <extension
         point="org.eclipse.ui.newWizards">
      <category
            id="org.eclipse.sapphire.newWizards"
            name="%category.name.0">
      </category>
     <wizard
           id="org.eclipse.sapphire.ui.wizards.NewSapphireModelCreationWizard"
           category="org.eclipse.sapphire.newWizards" 
           name="New Sapphire Model" 
           icon="icons/sapphire-32.png" 
           class="org.eclipse.sapphire.ui.wizards.NewSapphireModelCreationWizard">
           <description>
              Creates new Sapphire Model Element (IModelElement)
           </description>
     </wizard>
    
   </extension>

</plugin>




Not sure I am missing something here, also am not sure of the order pages, ideally i feel that Super classes addPages will be called first and then it will lead to sub class addPage - if that is the scenario then any way we could control the order ?

~Kamesh
Re: Extending Sapphire Wizards [message #721425 is a reply to message #721415] Thu, 01 September 2011 14:03 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 937
Registered: July 2009
Senior Member
It's hard to tell from this what is the problem. You will need to trap the exception that is thrown during construction of NewSapphireModelCreationWizard. Unfortunately Eclipse doesn't log this exception. You may be able to catch it by telling the debugger to break on all exceptions...

Regarding the approach... I probably wouldn't try to re-use JDT's new interface wizard page. The options that it allows aren't all applicable to Sapphire types (like picking arbitrary interfaces to extend).

- Konstantin
Re: Extending Sapphire Wizards [message #721429 is a reply to message #721425] Thu, 01 September 2011 14:16 Go to previous messageGo to next message
Kamesh Sampath is currently offline Kamesh Sampath
Messages: 213
Registered: July 2009
Senior Member
so you feel its ideal to build the wizard from the scratch and finally build the Interface out of it using the Template plugins ?

1. Even if we build a completly new Wizard using SDEF is there a way by which I can add that wizard to the plugin.xml and there by categorize and make it available via the Work bench Wizards Dialog

2. I also observed the same classes or wizard definition is working fine when i handle it with WizardDialog which is invoked via the Handlers, but its not working when I define my own CustomWizard class as shown below and adding it via the plugin.xml,

lets leave JDT interface wizard page, and use same sdef for both cases #1 and #2 mentioned above. Not sure why its failing to be invoked from Workbench New Wizard Dialog



~Kamesh

[Updated on: Thu, 01 September 2011 14:49]

Report message to a moderator

Re: Extending Sapphire Wizards [message #721462 is a reply to message #721429] Thu, 01 September 2011 16:15 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 937
Registered: July 2009
Senior Member
> so you feel its ideal to build the wizard from the scratch and finally
> build the Interface out of it using the Template plugins ?

Yes... I think the results would be better if you didn't try to re-use the JDT wizard page.

It is certainly possible to register Sapphire-based wizards via plugin.xml. All that that extension point requires is a class that extends Wizard, is not abstract and has a public zero-argument constructor. So you subclass SapphireWizard and create a zero argument constructor that initialized the wizard with model and sdef.

- Konstantin
Re: Extending Sapphire Wizards [message #721541 is a reply to message #721462] Fri, 02 September 2011 00:30 Go to previous messageGo to next message
Kamesh Sampath is currently offline Kamesh Sampath
Messages: 213
Registered: July 2009
Senior Member
Thanks Konstantin ! Here is the way to do it, I made change to make it work with plugin.xml registration is that the custom wizard other than extending from SapphireWizard<M> it needs to implement org.eclipse.ui.INewWizard

Other wise it will throw a ClassCastException that it can't cast the CustomWizard to IWorkbenchWizard ...

I will try to post an WIKI article on this - if you feel it adds value .

~Kamesh
Re: Extending Sapphire Wizards [message #721713 is a reply to message #721541] Fri, 02 September 2011 12:32 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 937
Registered: July 2009
Senior Member
> I will try to post an WIKI article on this - if you feel it adds value .

Sure. Sharing the knowledge is always a good thing.

- Konstantin
Re: Extending Sapphire Wizards [message #721714 is a reply to message #721713] Fri, 02 September 2011 12:34 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 937
Registered: July 2009
Senior Member
BTW... You should be extending SapphireWizard _and_ implementing INewWizard since INewWizard is additive to IWizard interface that is already implemented by SapphireWizard.

- Konstantin
Re: Extending Sapphire Wizards [message #721741 is a reply to message #721713] Fri, 02 September 2011 13:40 Go to previous messageGo to next message
Kamesh Sampath is currently offline Kamesh Sampath
Messages: 213
Registered: July 2009
Senior Member
I am not able to create a new page @ http://wiki.eclipse.org/Sapphire, do i need any permission or i need to create a page in other location and add a link to this page ?

~Kamesh
Re: Extending Sapphire Wizards [message #721747 is a reply to message #721741] Fri, 02 September 2011 13:57 Go to previous message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 937
Registered: July 2009
Senior Member
You need to login with bugzilla credentials.
Previous Topic:Code Generation
Next Topic:WIKI Article - Extending Sapphire Wizards
Goto Forum:
  


Current Time: Tue Jul 29 00:44:57 EDT 2014

Powered by FUDForum. Page generated in 0.02078 seconds