简体   繁体   中英

How to set the title of wizard window in Eclipse RCP 3.x?

How to set the title of wizard window in Eclipse RCP 3.x?

This code

    Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();
    WizardDialog dialog = new WizardDialog(shell, new ChatNewWizard());
    dialog.setTitle("New chat");
    dialog.open();

executed from handler, has no effect.

This code

getShell().setText("New chat");

and this code

((WizardDialog)getContainer()).setTitle("New chat");

both executed from addPages() also have no effect.

UPDATE

The following code

public class RunWizardHandler extends AbstractHandler {

    public static class MyWizardPage extends WizardPage {

        protected MyWizardPage() {
            super("Page Name", "Page Title", null);
            setDescription("Page Description");
        }

        @Override
        public void createControl(Composite parent) {

            Composite composite = new Composite(parent, SWT.NONE);
            composite.setLayout(new FillLayout());

            Label label = new Label(composite, SWT.NONE);
            label.setText("Label Text");

            setControl(composite);
        }

    }

    public static class MyWizard extends Wizard {

        @Override
        public void addPages() {
            addPage(new MyWizardPage());
        }

        @Override
        public boolean performFinish() {
            return false;
        }

    }

    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {
        Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();
        WizardDialog dialog = new WizardDialog(shell, new MyWizard());
        dialog.open(); 

        return event;
    }



}

ran from simple sample, gives the following window

在此处输入图片说明

Ie it places "Page Title" into location 1 , while I want to set text in location 2 .

Use the WizardPage(String pageName, String title, ImageDescriptor titleImage) constructor to specify a title for each page. Or call WizardPage.setTitle(xxx) whenever you want to change the title.

The current wizard page title overrides the normal dialog title (even if it is not set).

Update: For the title in the dialog tile bar use the WizardDialog.setWindowTitle call (usually in the constructor).

I'm not sure this is the best way but at least it worked for me:

    WizardDialog dialog = new WizardDialog(shell, wizard) {
        @Override
        public void create() {
            super.create();
            getShell().setText("Some nice window name");
        }
    };

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM