Search in sources :

Example 1 with WindupServerCallbackAdapter

use of org.jboss.tools.windup.ui.util.WindupServerCallbackAdapter in project windup-eclipse-plugin by windup.

the class WindupUiTest method runWindup.

protected void runWindup(ConfigurationElement configuration) {
    if (windupClient.isWindupServerRunning()) {
        System.out.println("MTA server already running.");
        Display.getDefault().syncExec(() -> {
            markerService.clear();
            // viewService.launchStarting();
            windupService.generateGraph(configuration, new NullProgressMonitor());
            // viewService.renderReport(configuration);
            markerService.generateMarkersForConfiguration(configuration);
        });
    } else {
        System.out.println("MTA server not running. Attempting to start it.");
        windupLauncher.start(new WindupServerCallbackAdapter(Display.getDefault().getActiveShell()) {

            @Override
            public void serverStart(IStatus status) {
                System.out.println("Finished attempt to start MTA server.");
                if (status.isOK() && windupClient.getExecutionBuilder() != null) {
                    System.out.println("MTA server started successfully.");
                    markerService.clear();
                    // viewService.launchStarting();
                    windupService.generateGraph(configuration, new NullProgressMonitor());
                    // viewService.renderReport(configuration);
                    markerService.generateMarkersForConfiguration(configuration);
                }
            }
        }, WindupRuntimePlugin.computeJRELocation());
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) WindupServerCallbackAdapter(org.jboss.tools.windup.ui.util.WindupServerCallbackAdapter)

Example 2 with WindupServerCallbackAdapter

use of org.jboss.tools.windup.ui.util.WindupServerCallbackAdapter in project windup-eclipse-plugin by windup.

the class IssueExplorer method createServerArea.

private void createServerArea(final Composite parent) {
    GridLayoutFactory.fillDefaults().spacing(0, 0).applyTo(parent);
    // GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);
    Composite top = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().spacing(0, 0).numColumns(2).applyTo(top);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(top);
    Composite container = new Composite(top, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(4).margins(0, 5).spacing(0, 0).applyTo(container);
    GridDataFactory.fillDefaults().indent(0, 0).grab(true, false).applyTo(container);
    serverImage = new Label(container, SWT.NONE);
    serverImage.setImage(WindupUIPlugin.getDefault().getImageRegistry().get(WindupUIPlugin.IMG_SERVER));
    textLabel = new Label(container, SWT.NONE);
    textLabel.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
    // $NON-NLS-1$
    textLabel.setText(Messages.WindupServerLabel);
    statusLabel = new Label(container, SWT.NONE);
    statusLabel.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.DECORATIONS_COLOR));
    Composite buttonBar = new Composite(top, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(3).margins(0, 5).spacing(12, 0).applyTo(buttonBar);
    GridDataFactory.fillDefaults().indent(0, 0).grab(false, false).applyTo(buttonBar);
    startStopButton = new CButton(buttonBar, SWT.NONE);
    startStopButton.setHotImage(WindupUIPlugin.getDefault().getImageRegistry().get(WindupUIPlugin.IMG_START));
    updateServerGroup();
    final Shell shell = parent.getShell();
    startStopButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (!windupClient.isWindupServerRunning()) {
                windupLauncher.shutdown(new WindupServerCallbackAdapter(shell) {

                    @Override
                    public void serverShutdown(IStatus status) {
                        Boolean shutdown;
                        if (status.isOK()) {
                            shutdown = Boolean.TRUE;
                        } else {
                            shutdown = Boolean.FALSE;
                            MessageDialog.openError(parent.getShell(), Messages.WindupShuttingDownError, status.getMessage());
                        }
                        if (shutdown) {
                            windupLauncher.start(new WindupServerCallbackAdapter(shell) {

                                @Override
                                public void windupNotExecutable() {
                                    MessageDialog.openError(parent.getShell(), Messages.WindupNotExecutableTitle, Messages.WindupNotExecutableInfo);
                                }

                                @Override
                                public void serverStart(IStatus status) {
                                    if (status.getSeverity() == IStatus.ERROR || !windupClient.isWindupServerRunning()) {
                                        StringBuilder builder = new StringBuilder();
                                        builder.append(Messages.WindupNotStartedMessage);
                                        builder.append(status.getMessage());
                                        builder.append(System.lineSeparator());
                                        builder.append(System.lineSeparator());
                                        builder.append(Messages.WindupNotStartedDebugInfo);
                                        builder.append(System.lineSeparator());
                                        builder.append(Messages.WindupStartNotStartingSolution1);
                                        builder.append(System.lineSeparator());
                                        builder.append(Messages.WindupStartNotStartingSolution2);
                                        builder.append(System.lineSeparator());
                                        builder.append(Messages.WindupStartNotStartingSolution3);
                                        builder.append(System.lineSeparator());
                                        builder.append(Messages.WindupStartNotStartingSolution4);
                                        builder.append(System.lineSeparator());
                                        builder.append(Messages.WindupStartNotStartingSolution5);
                                        RHAMTStartupFailedDialog dialog = new RHAMTStartupFailedDialog(Display.getDefault().getActiveShell());
                                        dialog.open();
                                    }
                                    updateServerGroup();
                                }
                            }, WindupRuntimePlugin.computeJRELocation());
                        }
                    }
                });
            } else {
                windupLauncher.shutdown(new WindupServerCallbackAdapter(shell) {

                    @Override
                    public void serverShutdown(IStatus status) {
                        Display.getDefault().asyncExec(() -> {
                            if (status.getSeverity() == Status.ERROR || !status.isOK()) {
                                MessageDialog.openError(parent.getShell(), Messages.WindupShuttingDownError, status.getMessage());
                            }
                            updateServerGroup();
                        });
                    }
                });
            }
        }
    });
    CButton preferenceButton = new CButton(buttonBar, SWT.NONE);
    preferenceButton.setHotImage(WindupUIPlugin.getDefault().getImageRegistry().get(WindupUIPlugin.IMG_CONFIG_HOT));
    preferenceButton.setColdImage(WindupUIPlugin.getDefault().getImageRegistry().get(WindupUIPlugin.IMG_CONFIG_COLD));
    // $NON-NLS-1$
    preferenceButton.setToolTipText("Configure MTA");
    preferenceButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // $NON-NLS-1$
            String id = "org.jboss.tools.windup.ui.preferences.WindupPreferencePage";
            PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(parent.getShell(), id, new String[] { id }, null);
            dialog.open();
        }
    });
    Composite separatorContainer = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(separatorContainer);
    GridDataFactory.fillDefaults().indent(0, 3).grab(true, false).applyTo(separatorContainer);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) StyledString(org.eclipse.jface.viewers.StyledString) WindupServerCallbackAdapter(org.jboss.tools.windup.ui.util.WindupServerCallbackAdapter) Shell(org.eclipse.swt.widgets.Shell) PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) RHAMTStartupFailedDialog(org.jboss.tools.windup.ui.internal.launch.RHAMTStartupFailedDialog) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 3 with WindupServerCallbackAdapter

use of org.jboss.tools.windup.ui.util.WindupServerCallbackAdapter in project windup-eclipse-plugin by windup.

the class WindupUiTest method init.

@Before
public void init() throws CoreException {
    projectProvider = workbenchBot.importProject(Activator.PLUGIN_ID, null, PROJECT, false);
    openWindupPerspective();
    this.issueExplorer = (IssueExplorer) ((CompatibilityView) partService.findPart(IssueExplorer.VIEW_ID).getObject()).getView();
    assertNotNull("Issue Explorer is NULL.", issueExplorer);
    System.out.println("@Before::init:: start MTA server.");
    windupLauncher.start(new WindupServerCallbackAdapter(Display.getDefault().getActiveShell()) {

        @Override
        public void serverStart(IStatus status) {
            if (status.isOK() && windupClient.getExecutionBuilder() != null) {
                System.out.println("@Before::init:: MTA server started successfully.");
            } else {
                System.out.println("@Before::init:: MTA server failed to start.");
            }
        }
    }, WindupRuntimePlugin.computeJRELocation());
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) WindupServerCallbackAdapter(org.jboss.tools.windup.ui.util.WindupServerCallbackAdapter) CompatibilityView(org.eclipse.ui.internal.e4.compatibility.CompatibilityView) Before(org.junit.Before)

Example 4 with WindupServerCallbackAdapter

use of org.jboss.tools.windup.ui.util.WindupServerCallbackAdapter in project windup-eclipse-plugin by windup.

the class WindupLaunchDelegate method restartAndRun.

private void restartAndRun(ConfigurationElement configuration, String jreHome) {
    launcher.shutdown(new WindupServerCallbackAdapter(shell) {

        @Override
        public void serverShutdown(IStatus status) {
            Boolean shutdown;
            if (status.isOK()) {
                shutdown = Boolean.TRUE;
            } else {
                shutdown = Boolean.FALSE;
                MessageDialog.openError(shell, Messages.WindupShuttingDownError, status.getMessage());
                // $NON-NLS-1$
                WindupUIPlugin.logErrorMessage("WindupLaunchDelegate:: unable to shutdown the MTA server. " + status.getMessage());
            }
            if (shutdown) {
                launcher.start(new WindupServerCallbackAdapter(shell) {

                    @Override
                    public void windupNotExecutable() {
                        MessageDialog.openError(shell, Messages.WindupNotExecutableTitle, Messages.WindupNotExecutableInfo);
                        // $NON-NLS-1$
                        WindupUIPlugin.logErrorMessage("WindupLaunchDelegate:: unable to start the MTA server. Script not executable.");
                    }

                    @Override
                    public void serverStart(IStatus status) {
                        if (status.getSeverity() == IStatus.ERROR || !windupClient.isWindupServerRunning()) {
                            StringBuilder builder = new StringBuilder();
                            builder.append(Messages.WindupNotStartedMessage);
                            builder.append(status.getMessage());
                            builder.append(System.lineSeparator());
                            builder.append(System.lineSeparator());
                            builder.append(Messages.WindupNotStartedDebugInfo);
                            builder.append(System.lineSeparator());
                            builder.append(Messages.WindupStartNotStartingSolution1);
                            builder.append(System.lineSeparator());
                            builder.append(Messages.WindupStartNotStartingSolution2);
                            builder.append(System.lineSeparator());
                            builder.append(Messages.WindupStartNotStartingSolution3);
                            builder.append(System.lineSeparator());
                            builder.append(Messages.WindupStartNotStartingSolution4);
                            builder.append(System.lineSeparator());
                            builder.append(Messages.WindupStartNotStartingSolution5);
                            RHAMTStartupFailedDialog dialog = new RHAMTStartupFailedDialog(Display.getDefault().getActiveShell());
                            dialog.open();
                            // $NON-NLS-1$
                            WindupUIPlugin.logErrorMessage("WindupLaunchDelegate:: Failed to start the MTA server. Message:" + status.getMessage());
                        }
                        if (windupClient.isWindupServerRunning()) {
                            runWindup(configuration);
                        }
                    }
                }, jreHome);
            }
        }
    });
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) WindupServerCallbackAdapter(org.jboss.tools.windup.ui.util.WindupServerCallbackAdapter)

Example 5 with WindupServerCallbackAdapter

use of org.jboss.tools.windup.ui.util.WindupServerCallbackAdapter in project windup-eclipse-plugin by windup.

the class WindupLaunchDelegate method launch.

public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) {
    ConfigurationElement configuration = modelService.findConfiguration(config.getName());
    if (configuration == null || configuration.getInputs().isEmpty()) {
        Display.getDefault().asyncExec(() -> {
            MessageDialog.openInformation(Display.getDefault().getActiveShell(), Messages.launchErrorTitle, Messages.launchErrorMessage);
            // $NON-NLS-1$
            WindupUIPlugin.logErrorMessage("WindupLaunchDelegate:: unable to launch MTA. Input is empty.");
        });
    } else {
        markerService.clear();
        String jreHome = configuration.getJreHome();
        if (jreHome == null || jreHome.trim().isEmpty()) {
            jreHome = WindupRuntimePlugin.computeJRELocation();
        }
        if (windupClient.isWindupServerRunning() && !windupClient.isJreRunning(jreHome)) {
            StringBuilder buff = new StringBuilder();
            // $NON-NLS-1$
            buff.append("Current JAVA_HOME: " + windupClient.getJavaHome());
            buff.append(System.lineSeparator());
            // $NON-NLS-1$
            buff.append("Restarting using JAVA_HOME: " + jreHome);
            WindupUIPlugin.getDefault().getLog().log(new Status(IStatus.INFO, WindupUIPlugin.PLUGIN_ID, buff.toString()));
            restartAndRun(configuration, jreHome);
        } else if (!windupClient.isWindupServerRunning()) {
            if (jreHome == null || jreHome.trim().isEmpty()) {
                jreHome = WindupRuntimePlugin.computeJRELocation();
            }
            launcher.start(new WindupServerCallbackAdapter(shell) {

                @Override
                public void windupNotExecutable() {
                    // $NON-NLS-1$
                    WindupUIPlugin.logErrorMessage("WindupLaunchDelegate:: unable to start the MTA server.");
                    MessageDialog.openError(shell, Messages.WindupNotExecutableTitle, Messages.WindupNotExecutableInfo);
                }

                @Override
                public void serverStart(IStatus status) {
                    if (status.getSeverity() == Status.ERROR) {
                        MessageDialog.openError(shell, Messages.WindupStartingError, status.getMessage());
                        // $NON-NLS-1$
                        WindupUIPlugin.logErrorMessage("WindupLaunchDelegate:: unable to start the MTA server. Message: " + status.getMessage());
                    }
                    if (status.isOK()) {
                        runWindup(configuration);
                    }
                }

                @Override
                public void serverShutdown(IStatus status) {
                }
            }, jreHome);
        } else {
            runWindup(configuration);
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ConfigurationElement(org.jboss.tools.windup.windup.ConfigurationElement) IStatus(org.eclipse.core.runtime.IStatus) WindupServerCallbackAdapter(org.jboss.tools.windup.ui.util.WindupServerCallbackAdapter)

Aggregations

IStatus (org.eclipse.core.runtime.IStatus)5 WindupServerCallbackAdapter (org.jboss.tools.windup.ui.util.WindupServerCallbackAdapter)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Status (org.eclipse.core.runtime.Status)1 PreferenceDialog (org.eclipse.jface.preference.PreferenceDialog)1 StyledString (org.eclipse.jface.viewers.StyledString)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 Shell (org.eclipse.swt.widgets.Shell)1 CompatibilityView (org.eclipse.ui.internal.e4.compatibility.CompatibilityView)1 RHAMTStartupFailedDialog (org.jboss.tools.windup.ui.internal.launch.RHAMTStartupFailedDialog)1 ConfigurationElement (org.jboss.tools.windup.windup.ConfigurationElement)1 Before (org.junit.Before)1