문제

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

enter image description here

I.e. 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");
        }
    };
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top