Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Dynamic Wizard Creation Problem
Dynamic Wizard Creation Problem [message #149693] Mon, 27 October 2003 12:24 Go to next message
Eclipse UserFriend
Originally posted by: batranip.in.ibm.com

Hi All,

I am facing a problem while creating a Wizard Page Dynamically (Reading
from XML file.)

In my application I add wizard pages dynamically. And based on the
selection of the present wizard page, next page appears.

Everything works fine if I click on next, but the momnet I click on the
previous button, change the option and then click next, the page does not
reflect the chnages according to the option selected.Instaed it shows the
page whcih I visted earlier (before clicking previous).

After putting log in my application I found that, for the first time
createControl(org.eclipse.swt.widgets.Composite parent) method is called
when I click on next, but If I go to previous page and then click on next
createControl() method is not called.

If anyone knows the solution, Please guide me where I am wrong

Here is the piece of code from the first wizard page.

StructurePage objStructurePage = null;
objStructurePage = new StructurePage("Assets",
selectedElement,familyName,this);
if (nextPageExists) {
currentWizard.addPage(objStructurePage);
return super.getNextPage();
}

Below is the attached code for StructurePage the page whcih keeps on adding

package com.ibm.irl.egov.dialog.wizard;
/*
* "The Java Developer's Guide to Eclipse"
* by Shavor, D'Anjou, Fairbrother, Kehn, Kellerman, McCarthy
*
* (C) Copyright International Business Machines Corporation, 2003.
* All Rights Reserved.
*
* Code or samples provided herein are provided without warranty of any
kind.
*/

import java.util.Hashtable;

import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.List;
import org.jdom.Element;

public class StructurePage extends WizardPage implements SelectionListener
{

// switch to control write of trace data
private boolean traceEnabled = true;

private Wizard currentWizard;
private WizardPage justParent;

private Button folderButton; // folder
private Button fileButton; // file
private Button noneButton;
private IStructuredSelection selection;

private boolean nextPageExists = false; // none
public org.eclipse.swt.widgets.Composite parent;

public Element thisPageRootElement;
public Element selectedElement;

public List nameList;
public List assetList;
public String familyName;
public Hashtable elementName;
String dummyData[];

/**
* Constructor for StructureInitPage.
* @param pageName
* @param selection
*/
public StructurePage(String pageName, IStructuredSelection selection,
Wizard parent, Element rootElement, String family, WizardPage justParent)
{
super(pageName);
System.out.println("Inside StructurePage "+nameList+" "+assetList+"
"+nameList+" "+assetList);
this.selection = selection;
System.out.println("1");
currentWizard = parent;
System.out.println("2 "+this.thisPageRootElement);
this.thisPageRootElement = rootElement;
System.out.println("3 rootElement"+thisPageRootElement.getName()+"
"+thisPageRootElement.getAttributeValue("name"));
this.familyName = family + "/" +
thisPageRootElement.getAttributeValue("name");
System.out.println("4");
this.justParent = justParent;
System.out.println("5");

setDescription("Choose the categoty and assets.");
setTitle("Category/Asset Navigation");
System.out.println("6");
elementName = new Hashtable();
System.out.println("Done");
}

/**
* Creates the top level dialog control under the given parent composite.
* <p>
* Implementors are responsible for ensuring that the created control can
* be accessed via <code>getControl</code>. This is done by identifying
the main
* control you create using the <code>setControl</code> method.
* </p>
*
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composit e)
*
* @param parent the parent composite
*/
public void createControl(org.eclipse.swt.widgets.Composite parent)
{

System.out.println("create control "+parent);
System.out.println("1");
// create a main control, with layout.
// If layout not provided, page content does not show
Composite composite = new Composite(parent, SWT.NONE);
System.out.println("2");
GridLayout compositeLayout = new GridLayout();
System.out.println("3");
compositeLayout.numColumns = 1;
compositeLayout.horizontalSpacing = 10;
compositeLayout.verticalSpacing = 10;
compositeLayout.marginHeight = 10;
compositeLayout.marginWidth = 10;
composite.setLayout(compositeLayout);
System.out.println("4");

GridData compositeData = new GridData(GridData.FILL_BOTH);
System.out.println("5");
compositeData.grabExcessHorizontalSpace = true;
System.out.println("6");
composite.setLayoutData(compositeData);
System.out.println("7");

// Create radio button group for dynamic page selection
createNextPageSelection(composite);
// identify main control for page
setControl(composite);
}

/**
* Utility method that creates a group with radio buttons that support
user
* selection of the next create resource wizard page.
*
* @param composite the parent for the new controls
*/
private Group createNextPageSelection(Composite composite)
{
System.out.println("Inside createNextPageSelection");
Group group = new Group(composite, SWT.NONE);
group.setText("Select the category from the list:");
GridData gData = new GridData(GridData.FILL_HORIZONTAL);
group.setLayoutData(gData);

GridLayout gLayout = new GridLayout();
gLayout.numColumns = 1;
group.setLayout(gLayout);

Group group2 = new Group(composite, SWT.NONE);
group.setText("Select the assets from the list:");
GridData gData2 = new GridData(GridData.FILL_HORIZONTAL);
group.setLayoutData(gData2);

GridLayout gLayout2 = new GridLayout();
gLayout.numColumns = 1;
group.setLayout(gLayout2);

nameList = createNameList(group);
assetList = createAssetList(group2);

return group;
}

private List createAssetList(Composite parent)
{
System.out.println("Inside createAssetList");
List list = new List(parent, SWT.SINGLE);
System.out.println("1");
list.setToolTipText("Assets");
list.setSize(200, 200);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
System.out.println("2 "+thisPageRootElement.getName());

java.util.List dataList = thisPageRootElement.getChildren();
System.out.println("3 "+dataList);
Element dummyElement = null;

for (int i = 0; i < dataList.size(); i++)
{
System.out.println("Inside loop "+dataList.get(i));
dummyElement = (Element) dataList.get(i);
System.out.println("dummyElement.getName() "+dummyElement.getName());
if (dummyElement.getName().equals("asset"))
{
list.add(dummyElement.getAttributeValue("name"));
elementName.put(dummyElement.getAttributeValue("name"), dummyElement);
}

}

System.out.println("4");
list.setLayoutData(data);
list.addSelectionListener(this);

return list;
}

/**
* Utility method that creates a radio button instance
* and sets the default layout data.
*
* @param parent the parent for the new button
* @param label the label for the new button
* @return the newly-created button
*/
private List createNameList(Composite parent)
{
System.out.println("Inside createNextPageSelection");
List list = new List(parent, SWT.SINGLE);
list.setToolTipText("Category");
list.setSize(200, 200);
GridData data = new GridData(GridData.FILL_HORIZONTAL);

java.util.List dataList = thisPageRootElement.getChildren();
Element dummyElement = null;

for (int i = 0; i < dataList.size(); i++)
{
dummyElement = (Element) dataList.get(i);

if (dummyElement.getName().equals("category"))
{
list.add(dummyElement.getAttributeValue("name"));
elementName.put(dummyElement.getAttributeValue("name"), dummyElement);
}

}

list.setLayoutData(data);
list.addSelectionListener(this);

return list;
}

/* non-Javadoc
*
* @see
org.eclipse.swt.events.SelectionListener#widgetDefaultSelect ed(SelectionEvent)
*/
public void widgetDefaultSelected(SelectionEvent e)
{
}

/**
* Event logic for radio button group. Identifies if another page has been
* selected so that the next button can be enabled.
*
* @see
org.eclipse.swt.events.SelectionListener#widgetSelected(Sele ctionEvent)
*/
public void widgetSelected(SelectionEvent e)
{
/*if (folderButton.getSelection()) {
// currentWizard.addPage(n);
System.out.println("new folder request");
nextPageExists = true;
}
else {
if (fileButton.getSelection()) {
System.out.println("new file request");
nextPageExists = true;
}
}*/

System.out.println("********* widgetSelected");
if (nameList.getSelectionCount() >= 1)
{
nextPageExists = true;
dummyData = nameList.getSelection();
System.out.println("********* dummyData " + dummyData.length + " " +
dummyData[0]);
selectedElement = (Element) elementName.get(dummyData[0]);
}
else
{
nextPageExists = false;
}

getWizard().getContainer().updateButtons();

}

/**
* Provides a next page based on the current selection.
* If a page has been requested it is added to the wizard first.
*
* The inherited <code>getNextPage</code>framework method is used to
* return the next page which was just added.
*
* @see org.eclipse.jface.wizard.IWizardPage#getNextPage()
*/
public IWizardPage getNextPage()
{
// add and then return folder page if requested
System.out.println("Inside getNextPage()");
if (nextPageExists)
{
System.out.println("********* Yes next page exist");
currentWizard.addPage(new StructurePage("Assets", selection,
currentWizard, selectedElement, familyName, this));
return super.getNextPage();
}

return null;
}

/**
* If another page exists the Next button will be enabled.
* This decision controlled by the <code>widgetSelected</code> event
logic
* for the radio button group.
*
* @see org.eclipse.jface.wizard.IWizardPage#canFlipToNextPage()
*/
public boolean canFlipToNextPage()
{
return nextPageExists;
}

/**
* Write trace statements.
* System.out.println with prefix tagging used for simplicity.
*/
private void traceMsg(String msg)
{
System.out.println(msg);
}

}
Re: Dynamic Wizard Creation Problem [message #1085604 is a reply to message #149693] Tue, 13 August 2013 05:45 Go to previous messageGo to next message
Sumit Singh is currently offline Sumit SinghFriend
Messages: 141
Registered: October 2012
Location: Bangalore
Senior Member

Please provide only useful code. Don't dump all your classes.


Thanks
Re: Dynamic Wizard Creation Problem [message #1779128 is a reply to message #149693] Wed, 03 January 2018 05:34 Go to previous messageGo to next message
prateek garg is currently offline prateek gargFriend
Messages: 17
Registered: August 2016
Junior Member
Did you find any solution?

~P
Re: Dynamic Wizard Creation Problem [message #1779129 is a reply to message #149693] Wed, 03 January 2018 05:35 Go to previous message
prateek garg is currently offline prateek gargFriend
Messages: 17
Registered: August 2016
Junior Member
No Message Body
Previous Topic:Show View Shortcuts adden
Next Topic:Extend Syntax Coloring
Goto Forum:
  


Current Time: Fri Jun 22 03:56:14 GMT 2018

Powered by FUDForum. Page generated in 0.02185 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top