0

Brief note about my work progress :

I'm currently working on JFace Wizards. There is a tableViewer in one of my wizards and a row in that table has a button which opens a dialog cell editor. Wizard also has a IRunnableWithProgress indicator which will be run in IRunnableContext.

Problem I'm facing :

The constructor in my Dialog cell editor class accepts two parameters :

public DialogEditor(Composite parent,IRunnableContext context)

While invoking the above constructor from another class, I can pass in a tableViewer object as an actual paramater for the formal parameter Composite parent but how do I invoke IRunnableContext? what do I pass in as a parameter for IRunnableContext? For example :

TableViewer tableViewer = new TableViewer(table);
DialogEditor dialogEditor = new DialogEditor(tableViewer, ???(What do I add here?))

After I googled and read few Java Docs I figured out that there is a method getContainer() in the org.eclipse.jface.wizard.IWizard class which returns the container of this wizard. But I'm not quite sure how to use the method getContainer() since its not a static method and I cannot instantiate the type IWizard.

An update to my question.

I tried implementing IWizard interface and use the getContainer() method but I received an exception :

"java.lang.Error: Unresolved compilation problem: IWizardContainer cannot be resolved"

This is the Java Doc of IWizard interface :

/**
 * Returns the container of this wizard.
 *
 * @return the wizard container, or <code>null</code> if this
 *   wizard has yet to be added to a container
 */
public IWizardContainer getContainer();

And this is my code :

public abstract class myWizard implements IWizard {
TableViewer tableViewer = new TableViewer(table);
DialogEditor dialogEditor = new DialogEditor(tableViewer, getContainer());
//other code
}

There are no compilation errors but I receive an exception when I click on the table row "java.lang.Error: Unresolved compilation problem: IWizardContainer cannot be resolved".

And also I do not want to implement the interface IWizard since my other classes which extend myWizard.class must implement the inherited abstract method IWizrad.getContainer() which is needless in other classes, Is there a workaround for this issue I'm facing?

Brian Tompsett - 汤莱恩
  • 5,195
  • 62
  • 50
  • 120

1 Answers1

0

The WizardPage which contains your code has a getContainer() method so you should just be able to do:

DialogEditor dialogEditor = new DialogEditor(tableViewer, getContainer());
greg-449
  • 102,836
  • 220
  • 90
  • 127
  • It says "The method getContainer() is undefined for the type DialogEditor". Should I implement the interface IWizard? How do I invoke getContainer()? – user3652212 Aug 13 '14 at 08:07
  • I tried implementing IWizard interface and use getContainer() method but I received an Exception "java.lang.Error: Unresolved compilation problem: IWizardContainer cannot be resolved". I have edited my question above to show my code, Please take a look. – user3652212 Aug 13 '14 at 08:14