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());
}
}
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);
}
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());
}
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);
}
}
});
}
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);
}
}
}
Aggregations