package com.bredexsw.guidancer.examples.aut.meters.ui.wizards; import java.util.Collection; import java.util.HashMap; import java.util.Map; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.wizard.IWizard; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; /** * This class extends WizardDialog. The reason for it is, * to give names to the dialog buttons. * */ public class NamedWizardDialog extends WizardDialog { /** collection of (button_id, name) pairs */ private static Collection> entries; static { HashMap map = new HashMap(); map.put(IDialogConstants.FINISH_ID, "ok"); //$NON-NLS-1$ map.put(IDialogConstants.CANCEL_ID, "cancel"); //$NON-NLS-1$ map.put(IDialogConstants.HELP_ID, "help"); //$NON-NLS-1$ map.put(IDialogConstants.NEXT_ID, "next"); //$NON-NLS-1$ map.put(IDialogConstants.BACK_ID, "back"); //$NON-NLS-1$ entries = map.entrySet(); }; /** * * @param parentShell shell * @param newWizard wizard */ public NamedWizardDialog(Shell parentShell, IWizard newWizard) { super(parentShell, newWizard); } /** * After creating the buttons, we give names to the buttons * * {@inheritDoc} * @see org.eclipse.jface.wizard.WizardDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) */ protected void createButtonsForButtonBar(Composite parent) { super.createButtonsForButtonBar(parent); // after creation of the buttons, we do assign names for (Map.Entry entry : entries) { Button btn = getButton(entry.getKey()); if (btn != null) { btn.setData("TEST_COMP_NAME", entry.getValue()); //$NON-NLS-1$ } } } }