use of org.apache.sling.ide.eclipse.core.ISlingLaunchpadConfiguration in project sling by apache.
the class DebugEditorSection method initialize.
private void initialize() {
final ISlingLaunchpadConfiguration config = launchpadServer.getConfiguration();
resolveSourcesButton.setSelection(config.resolveSourcesInDebugMode());
SelectionListener listener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
execute(new SetResolveSourcesCommand(server, resolveSourcesButton.getSelection()));
}
};
resolveSourcesButton.addSelectionListener(listener);
}
use of org.apache.sling.ide.eclipse.core.ISlingLaunchpadConfiguration in project sling by apache.
the class InstallEditorSection method initialize.
private void initialize() {
final ISlingLaunchpadConfiguration config = launchpadServer.getConfiguration();
quickLocalInstallButton.setSelection(config.bundleInstallLocally());
bundleLocalInstallButton.setSelection(!config.bundleInstallLocally());
SelectionListener listener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
execute(new SetBundleInstallLocallyCommand(server, quickLocalInstallButton.getSelection()));
}
};
quickLocalInstallButton.addSelectionListener(listener);
bundleLocalInstallButton.addSelectionListener(listener);
}
use of org.apache.sling.ide.eclipse.core.ISlingLaunchpadConfiguration in project sling by apache.
the class JVMDebuggerConnection method connectInDebugMode.
boolean connectInDebugMode(ILaunch launch, IServer iServer, IProgressMonitor monitor) throws CoreException {
long start = System.currentTimeMillis();
this.launch = launch;
boolean success = false;
IVMConnector connector = null;
connector = JavaRuntime.getVMConnector(IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR);
if (connector == null) {
connector = JavaRuntime.getDefaultVMConnector();
}
if (connector == null) {
throw new CoreException(new Status(IStatus.ERROR, "org.apache.sling.ide.eclipse.wst", "Could not get jvm connctor"));
}
ISlingLaunchpadServer launchpadServer = (ISlingLaunchpadServer) iServer.loadAdapter(SlingLaunchpadServer.class, monitor);
ISlingLaunchpadConfiguration configuration = launchpadServer.getConfiguration();
int debugPort = configuration.getDebugPort();
if (debugPort <= 0) {
throw new CoreException(new Status(IStatus.ERROR, "org.apache.sling.ide.eclipse.wst", "debug port not configured"));
}
Map<String, String> connectMap = new HashMap<>();
connectMap.put("hostname", iServer.getHost());
connectMap.put("port", String.valueOf(debugPort));
// Map argMap = null;//configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, (Map)null);
int connectTimeout = JavaRuntime.getPreferences().getInt(JavaRuntime.PREF_CONNECT_TIMEOUT);
//$NON-NLS-1$
connectMap.put("timeout", Integer.toString(connectTimeout));
// set the default source locator if required
@SuppressWarnings("restriction") ISourceLookupDirector sourceLocator = new JavaSourceLookupDirector();
sourceLocator.setSourcePathComputer(DebugPlugin.getDefault().getLaunchManager().getSourcePathComputer(//$NON-NLS-1$
"org.eclipse.jdt.launching.sourceLookup.javaSourcePathComputer"));
List<IRuntimeClasspathEntry> classpathEntries = new ArrayList<>();
// 1. add java projects first
for (IJavaProject javaProject : ProjectHelper.getAllJavaProjects()) {
classpathEntries.add(JavaRuntime.newProjectRuntimeClasspathEntry(javaProject));
}
// 2. add the other modules deployed on server
// 5/30
ProgressUtils.advance(monitor, 5);
// 30 - 5 - 1
int workTicksForReferences = 24;
SourceReferenceResolver resolver = Activator.getDefault().getSourceReferenceResolver();
if (resolver != null && configuration.resolveSourcesInDebugMode()) {
try {
List<SourceReference> references = osgiClient.findSourceReferences();
SubMonitor subMonitor = SubMonitor.convert(monitor, "Resolving source references", workTicksForReferences).setWorkRemaining(references.size());
for (SourceReference reference : references) {
try {
subMonitor.setTaskName("Resolving source reference: " + reference);
IRuntimeClasspathEntry classpathEntry = resolver.resolve(reference);
if (classpathEntry != null) {
classpathEntries.add(classpathEntry);
}
ProgressUtils.advance(subMonitor, 1);
} catch (CoreException e) {
// don't fail the debug launch for artifact resolution errors
Activator.getDefault().getPluginLogger().warn("Failed resolving source reference", e);
}
}
// 29/30
subMonitor.done();
} catch (OsgiClientException e1) {
throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID, e1.getMessage(), e1));
}
} else {
monitor.worked(workTicksForReferences);
}
// 3. add the JRE entry
classpathEntries.add(JavaRuntime.computeJREEntry(launch.getLaunchConfiguration()));
IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath(classpathEntries.toArray(new IRuntimeClasspathEntry[0]), launch.getLaunchConfiguration());
sourceLocator.setSourceContainers(JavaRuntime.getSourceContainers(resolved));
sourceLocator.initializeParticipants();
launch.setSourceLocator(sourceLocator);
// connect to remote VM
try {
// 30/30
connector.connect(connectMap, monitor, launch);
success = true;
long elapsedMillis = System.currentTimeMillis() - start;
Activator.getDefault().getPluginLogger().tracePerformance("Debug connection to {0}", elapsedMillis, iServer.getName());
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, "org.apache.sling.ide.eclipse.wst", "could not establish debug connection to " + iServer.getHost() + " : " + debugPort, e));
}
return success;
}
use of org.apache.sling.ide.eclipse.core.ISlingLaunchpadConfiguration in project sling by apache.
the class ConnectionEditorSection method initialize.
private void initialize() {
final ISlingLaunchpadConfiguration config = launchpadServer.getConfiguration();
portText.setText(String.valueOf(config.getPort()));
debugPortText.setText(String.valueOf(config.getDebugPort()));
contextPathText.setText(config.getContextPath());
usernameText.setText(config.getUsername());
passwordText.setText(config.getPassword());
ModifyListener listener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (updating) {
return;
}
updating = true;
try {
if (e.getSource() == portText) {
try {
int port = Integer.parseInt(portText.getText());
execute(new SetServerPortCommand(server, port));
} catch (NumberFormatException ex) {
// shucks
}
} else if (e.getSource() == debugPortText) {
try {
int debugPort = Integer.parseInt(debugPortText.getText());
execute(new SetServerDebugPortCommand(server, debugPort));
} catch (NumberFormatException ex) {
// shucks
ex.printStackTrace();
}
} else if (e.getSource() == contextPathText) {
execute(new SetServerContextPathCommand(server, contextPathText.getText()));
} else if (e.getSource() == usernameText) {
execute(new SetServerUsernameCommand(server, usernameText.getText()));
} else if (e.getSource() == passwordText) {
execute(new SetServerPasswordCommand(server, passwordText.getText()));
}
} finally {
updating = false;
}
}
};
for (Text text : new Text[] { portText, debugPortText, contextPathText, usernameText, passwordText }) {
text.addModifyListener(listener);
}
}
Aggregations