Search in sources :

Example 1 with WizardFragment

use of org.eclipse.wst.server.ui.wizard.WizardFragment in project liferay-ide by liferay.

the class CleanAppServerAction method showWizard.

protected int showWizard(IRuntimeWorkingCopy runtimeWorkingCopy) {
    String title = Msgs.wizEditRuntimeWizardTitle;
    WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(runtimeWorkingCopy.getRuntimeType().getId());
    if (fragment2 == null) {
        return Window.CANCEL;
    }
    TaskModel taskModel = new TaskModel();
    taskModel.putObject(TaskModel.TASK_RUNTIME, runtimeWorkingCopy);
    WizardFragment fragment = new WizardFragment() {

        protected void createChildFragments(List<WizardFragment> list) {
            list.add((WizardFragment) fragment2.getChildFragments().get(0));
            list.add(WizardTaskUtil.SaveRuntimeFragment);
        }
    };
    TaskWizard wizard = new TaskWizard(title, fragment, taskModel);
    wizard.setForcePreviousAndNextButtons(true);
    WizardDialog dialog = new WizardDialog(getDisplay().getActiveShell(), wizard);
    return dialog.open();
}
Also used : WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) List(java.util.List) WizardDialog(org.eclipse.jface.wizard.WizardDialog) TaskModel(org.eclipse.wst.server.core.TaskModel) TaskWizard(org.eclipse.wst.server.ui.internal.wizard.TaskWizard)

Example 2 with WizardFragment

use of org.eclipse.wst.server.ui.wizard.WizardFragment in project webtools.servertools by eclipse.

the class TomcatRuntimeComposite method createControl.

/**
 * Provide a wizard page to change the Tomcat installation directory.
 */
protected void createControl() {
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    setLayout(layout);
    setLayoutData(new GridData(GridData.FILL_BOTH));
    PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ContextIds.RUNTIME_COMPOSITE);
    Label label = new Label(this, SWT.NONE);
    label.setText(Messages.runtimeName);
    GridData data = new GridData();
    data.horizontalSpan = 2;
    label.setLayoutData(data);
    name = new Text(this, SWT.BORDER);
    data = new GridData(GridData.FILL_HORIZONTAL);
    name.setLayoutData(data);
    name.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            runtimeWC.setName(name.getText());
            validate();
        }
    });
    label = new Label(this, SWT.NONE);
    label.setText(Messages.installDir);
    data = new GridData();
    data.horizontalSpan = 2;
    label.setLayoutData(data);
    installDir = new Text(this, SWT.BORDER);
    data = new GridData(GridData.FILL_HORIZONTAL);
    installDir.setLayoutData(data);
    installDir.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            runtimeWC.setLocation(new Path(installDir.getText()));
            validate();
        }
    });
    Button browse = SWTUtil.createButton(this, Messages.browse);
    browse.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent se) {
            DirectoryDialog dialog = new DirectoryDialog(TomcatRuntimeComposite.this.getShell());
            dialog.setMessage(Messages.selectInstallDir);
            dialog.setFilterPath(installDir.getText());
            String selectedDirectory = dialog.open();
            if (selectedDirectory != null)
                installDir.setText(selectedDirectory);
        }
    });
    installLabel = new Label(this, SWT.RIGHT);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalIndent = 10;
    installLabel.setLayoutData(data);
    install = SWTUtil.createButton(this, Messages.install);
    install.setEnabled(false);
    install.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent se) {
            String license = null;
            try {
                license = ir.getLicense(new NullProgressMonitor());
            } catch (CoreException e) {
                Trace.trace(Trace.SEVERE, "Error getting license", e);
            }
            TaskModel taskModel = new TaskModel();
            taskModel.putObject(LicenseWizardFragment.LICENSE, license);
            TaskWizard wizard2 = new TaskWizard(Messages.installDialogTitle, new WizardFragment() {

                protected void createChildFragments(List list) {
                    list.add(new LicenseWizardFragment());
                }
            }, taskModel);
            WizardDialog dialog2 = new WizardDialog(getShell(), wizard2);
            if (dialog2.open() == Window.CANCEL)
                return;
            DirectoryDialog dialog = new DirectoryDialog(TomcatRuntimeComposite.this.getShell());
            dialog.setMessage(Messages.selectInstallDir);
            dialog.setFilterPath(installDir.getText());
            String selectedDirectory = dialog.open();
            if (selectedDirectory != null) {
                // ir.install(new Path(selectedDirectory));
                final IPath installPath = new Path(selectedDirectory);
                installRuntimeJob = new Job("Installing server runtime environment") {

                    public boolean belongsTo(Object family) {
                        return ServerPlugin.PLUGIN_ID.equals(family);
                    }

                    protected IStatus run(IProgressMonitor monitor) {
                        try {
                            ir.install(installPath, monitor);
                        } catch (CoreException ce) {
                            return ce.getStatus();
                        }
                        return Status.OK_STATUS;
                    }
                };
                installDir.setText(selectedDirectory);
                jobListener = new JobChangeAdapter() {

                    public void done(IJobChangeEvent event) {
                        installRuntimeJob.removeJobChangeListener(this);
                        installRuntimeJob = null;
                        Display.getDefault().asyncExec(new Runnable() {

                            public void run() {
                                if (!isDisposed()) {
                                    validate();
                                }
                            }
                        });
                    }
                };
                installRuntimeJob.addJobChangeListener(jobListener);
                installRuntimeJob.schedule();
            }
        }
    });
    updateJREs();
    // JDK location
    label = new Label(this, SWT.NONE);
    label.setText(Messages.installedJRE);
    data = new GridData();
    data.horizontalSpan = 2;
    label.setLayoutData(data);
    combo = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY);
    combo.setItems(jreNames);
    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    combo.setLayoutData(data);
    combo.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            int sel = combo.getSelectionIndex();
            IVMInstall vmInstall = null;
            if (sel > 0)
                vmInstall = (IVMInstall) installedJREs.get(sel - 1);
            runtime.setVMInstall(vmInstall);
            validate();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    Button button = SWTUtil.createButton(this, Messages.installedJREs);
    button.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            String currentVM = combo.getText();
            if (showPreferencePage()) {
                updateJREs();
                combo.setItems(jreNames);
                combo.setText(currentVM);
                if (combo.getSelectionIndex() == -1)
                    combo.select(0);
                validate();
            }
        }
    });
    init();
    validate();
    Dialog.applyDialogFont(this);
    name.forceFocus();
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ModifyListener(org.eclipse.swt.events.ModifyListener) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List) Job(org.eclipse.core.runtime.jobs.Job) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) LicenseWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment) IPath(org.eclipse.core.runtime.IPath) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) TaskWizard(org.eclipse.wst.server.ui.internal.wizard.TaskWizard) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IVMInstall(org.eclipse.jdt.launching.IVMInstall) LicenseWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment) GridData(org.eclipse.swt.layout.GridData) WizardDialog(org.eclipse.jface.wizard.WizardDialog) TaskModel(org.eclipse.wst.server.core.TaskModel) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 3 with WizardFragment

use of org.eclipse.wst.server.ui.wizard.WizardFragment in project webtools.servertools by eclipse.

the class ServerUIPlugin method showNewServerWizard.

/**
 * Open the new server wizard.
 *
 * @param shell a shell
 * @param typeId a module type id, or null for any module type
 * @param versionId a module version, or null for any version
 * @param serverTypeId a server runtime type, or null for any type
 * @return <code>true</code> if a server was created, or
 *    <code>false</code> otherwise
 */
public static boolean showNewServerWizard(Shell shell, final String typeId, final String versionId, final String serverTypeId) {
    WizardFragment fragment = new WizardFragment() {

        protected void createChildFragments(List<WizardFragment> list) {
            list.add(new NewServerWizardFragment(new ModuleType(typeId, versionId), serverTypeId));
            list.add(WizardTaskUtil.TempSaveRuntimeFragment);
            list.add(WizardTaskUtil.TempSaveServerFragment);
            list.add(new ModifyModulesWizardFragment());
            list.add(new TasksWizardFragment());
            list.add(WizardTaskUtil.SaveRuntimeFragment);
            list.add(WizardTaskUtil.SaveServerFragment);
            list.add(WizardTaskUtil.SaveHostnameFragment);
        }
    };
    TaskWizard wizard = new TaskWizard(Messages.wizNewServerWizardTitle, fragment);
    wizard.setForcePreviousAndNextButtons(true);
    WizardDialog dialog = new WizardDialog(shell, wizard);
    return (dialog.open() == IDialogConstants.OK_ID);
}
Also used : WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) WizardDialog(org.eclipse.jface.wizard.WizardDialog) TaskWizard(org.eclipse.wst.server.ui.internal.wizard.TaskWizard)

Example 4 with WizardFragment

use of org.eclipse.wst.server.ui.wizard.WizardFragment in project webtools.servertools by eclipse.

the class RuntimePreferencePage method showWizard.

protected int showWizard(final IRuntimeWorkingCopy runtimeWorkingCopy) {
    String title = null;
    WizardFragment fragment = null;
    TaskModel taskModel = new TaskModel();
    if (runtimeWorkingCopy == null) {
        title = Messages.wizNewRuntimeWizardTitle;
        fragment = new WizardFragment() {

            protected void createChildFragments(List<WizardFragment> list) {
                list.add(new NewRuntimeWizardFragment());
                list.add(WizardTaskUtil.SaveRuntimeFragment);
            }
        };
    } else {
        title = Messages.wizEditRuntimeWizardTitle;
        final WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(runtimeWorkingCopy.getRuntimeType().getId());
        if (fragment2 == null) {
            edit.setEnabled(false);
            return Window.CANCEL;
        }
        taskModel.putObject(TaskModel.TASK_RUNTIME, runtimeWorkingCopy);
        fragment = new WizardFragment() {

            protected void createChildFragments(List<WizardFragment> list) {
                list.add(fragment2);
                list.add(WizardTaskUtil.SaveRuntimeFragment);
            }
        };
    }
    TaskWizard wizard = new TaskWizard(title, fragment, taskModel);
    wizard.setForcePreviousAndNextButtons(true);
    WizardDialog dialog = new WizardDialog(getShell(), wizard);
    return dialog.open();
}
Also used : NewRuntimeWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.NewRuntimeWizardFragment) WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) NewRuntimeWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.NewRuntimeWizardFragment) WizardDialog(org.eclipse.jface.wizard.WizardDialog) TaskWizard(org.eclipse.wst.server.ui.internal.wizard.TaskWizard)

Example 5 with WizardFragment

use of org.eclipse.wst.server.ui.wizard.WizardFragment in project webtools.servertools by eclipse.

the class ServerUIPlugin method showNewRuntimeWizard.

/**
 * Open the new runtime wizard.
 *
 * @param shell a shell
 * @param type a module type id
 * @param version a module version id
 * @param runtimeTypeId a runtime type id
 * @return true if a new runtime was created
 */
public static boolean showNewRuntimeWizard(Shell shell, final String type, final String version, final String runtimeTypeId) {
    WizardFragment fragment = new WizardFragment() {

        protected void createChildFragments(List<WizardFragment> list) {
            list.add(new NewRuntimeWizardFragment(type, version, runtimeTypeId));
            list.add(WizardTaskUtil.SaveRuntimeFragment);
        }
    };
    TaskWizard wizard = new TaskWizard(Messages.wizNewRuntimeWizardTitle, fragment);
    wizard.setForcePreviousAndNextButtons(true);
    WizardDialog dialog = new WizardDialog(shell, wizard);
    return (dialog.open() == IDialogConstants.OK_ID);
}
Also used : WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) WizardDialog(org.eclipse.jface.wizard.WizardDialog) TaskWizard(org.eclipse.wst.server.ui.internal.wizard.TaskWizard)

Aggregations

WizardFragment (org.eclipse.wst.server.ui.wizard.WizardFragment)22 WizardDialog (org.eclipse.jface.wizard.WizardDialog)9 TaskWizard (org.eclipse.wst.server.ui.internal.wizard.TaskWizard)9 LicenseWizardFragment (org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment)7 DownloadableAdapterLicenseWizardFragment (org.eclipse.wst.server.ui.internal.wizard.fragment.DownloadableAdapterLicenseWizardFragment)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 List (java.util.List)5 CoreException (org.eclipse.core.runtime.CoreException)5 ArrayList (java.util.ArrayList)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)3 TaskModel (org.eclipse.wst.server.core.TaskModel)3 Job (org.eclipse.core.runtime.jobs.Job)2 File (java.io.File)1 IOException (java.io.IOException)1 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)1 IPath (org.eclipse.core.runtime.IPath)1 IStatus (org.eclipse.core.runtime.IStatus)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1