Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[eclipse] Add SARL application launch configuration.
see #745 Signed-off-by: Stéphane Galland <galland@arakhne.org>
- Loading branch information
1 parent
73a5684
commit cb52066
Showing
4 changed files
with
336 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...ipse/src/io/sarl/eclipse/launching/dialog/SARLApplicationLaunchConfigurationTabGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* $Id$ | ||
* | ||
* SARL is an general-purpose agent programming language. | ||
* More details on http://www.sarl.io | ||
* | ||
* Copyright (C) 2014-2018 the original authors or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.sarl.eclipse.launching.dialog; | ||
|
||
import org.eclipse.debug.ui.CommonTab; | ||
import org.eclipse.debug.ui.EnvironmentTab; | ||
import org.eclipse.debug.ui.ILaunchConfigurationDialog; | ||
import org.eclipse.debug.ui.ILaunchConfigurationTab; | ||
import org.eclipse.debug.ui.sourcelookup.SourceLookupTab; | ||
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaArgumentsTab; | ||
|
||
/** | ||
* Tab group object for configuring the run of a Java application embedding SARL. | ||
* | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
* @since 0.7 | ||
*/ | ||
public class SARLApplicationLaunchConfigurationTabGroup extends AbstractSARLLaunchConfigurationTabGroup { | ||
|
||
@Override | ||
public void createTabs(ILaunchConfigurationDialog dialog, String mode) { | ||
final ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] { | ||
new SARLApplicationMainLaunchConfigurationTab(), | ||
new JavaArgumentsTab(), | ||
new SARLRuntimeEnvironmentTab(false), | ||
getClasspathTab(dialog), | ||
new SourceLookupTab(), | ||
new EnvironmentTab(), | ||
new CommonTab(), | ||
}; | ||
setTabs(tabs); | ||
} | ||
|
||
} |
187 changes: 187 additions & 0 deletions
187
...lipse/src/io/sarl/eclipse/launching/dialog/SARLApplicationMainLaunchConfigurationTab.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
/* | ||
* $Id$ | ||
* | ||
* SARL is an general-purpose agent programming language. | ||
* More details on http://www.sarl.io | ||
* | ||
* Copyright (C) 2014-2018 the original authors or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.sarl.eclipse.launching.dialog; | ||
|
||
import java.lang.ref.SoftReference; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.eclipse.debug.core.ILaunchConfiguration; | ||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; | ||
import org.eclipse.debug.internal.ui.SWTFactory; | ||
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaMainTab; | ||
import org.eclipse.jdt.internal.debug.ui.launcher.LauncherMessages; | ||
import org.eclipse.swt.events.SelectionEvent; | ||
import org.eclipse.swt.events.SelectionListener; | ||
import org.eclipse.swt.graphics.Image; | ||
import org.eclipse.swt.layout.GridData; | ||
import org.eclipse.swt.layout.GridLayout; | ||
import org.eclipse.swt.widgets.Button; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.swt.widgets.Group; | ||
|
||
import io.sarl.eclipse.SARLEclipseConfig; | ||
import io.sarl.eclipse.SARLEclipsePlugin; | ||
import io.sarl.eclipse.launching.config.ILaunchConfigurationAccessor; | ||
import io.sarl.eclipse.launching.config.ILaunchConfigurationConfigurator; | ||
|
||
/** | ||
* The main launch configuration tab for SARL applications. | ||
* | ||
* <p>This configuration tab enables to enter the name of the main class to launch, | ||
* the launching parameters. | ||
* | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
* @since 0.7 | ||
*/ | ||
public class SARLApplicationMainLaunchConfigurationTab extends JavaMainTab { | ||
|
||
private volatile SoftReference<Image> image; | ||
|
||
private Button runInEclipseButton; | ||
|
||
private Button enableAssertionsInDebugModeButton; | ||
|
||
private Button enableAssertionsInRunModeButton; | ||
|
||
private final WidgetListener defaultListener = new WidgetListener(); | ||
|
||
@Inject | ||
private ILaunchConfigurationConfigurator configurator; | ||
|
||
@Inject | ||
private ILaunchConfigurationAccessor accessor; | ||
|
||
/** Construct a main configuration tab for SARL application. | ||
*/ | ||
public SARLApplicationMainLaunchConfigurationTab() { | ||
// | ||
} | ||
|
||
@Override | ||
public Image getImage() { | ||
Image img = (this.image == null) ? null : this.image.get(); | ||
if (img == null) { | ||
img = SARLEclipsePlugin.getDefault().getImage(SARLEclipseConfig.SARL_APPLICATION_IMAGE); | ||
this.image = new SoftReference<>(img); | ||
} | ||
return img; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return "io.sarl.eclipse.debug.ui.sarlApplicationMainTab"; //$NON-NLS-1$ | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return Messages.MainLaunchConfigurationTab_7; | ||
} | ||
|
||
@Override | ||
public void createControl(Composite parent) { | ||
super.createControl(parent); | ||
final Composite comp = SWTFactory.createComposite(parent, parent.getFont(), 1, 1, GridData.FILL_BOTH); | ||
((GridLayout) comp.getLayout()).verticalSpacing = 0; | ||
createProjectEditor(comp); | ||
createVerticalSpacer(comp, 1); | ||
createMainTypeEditor(comp, LauncherMessages.JavaMainTab_Main_cla_ss__4); | ||
createVerticalSpacer(comp, 1); | ||
createLaunchOptionEditor(comp, Messages.MainLaunchConfigurationTab_10); | ||
setControl(comp); | ||
} | ||
|
||
/** | ||
* Creates the widgets for configuring the launch options. | ||
* | ||
* @param parent the parent composite. | ||
* @param text the label of the group. | ||
*/ | ||
protected void createLaunchOptionEditor(Composite parent, String text) { | ||
final Group group = SWTFactory.createGroup(parent, text, 1, 1, GridData.FILL_HORIZONTAL); | ||
this.enableAssertionsInRunModeButton = createCheckButton(group, Messages.SARLMainLaunchConfigurationTab_2); | ||
this.enableAssertionsInRunModeButton.addSelectionListener(this.defaultListener); | ||
this.enableAssertionsInDebugModeButton = createCheckButton(group, Messages.SARLMainLaunchConfigurationTab_1); | ||
this.enableAssertionsInDebugModeButton.addSelectionListener(this.defaultListener); | ||
this.runInEclipseButton = createCheckButton(group, Messages.SARLMainLaunchConfigurationTab_0); | ||
this.runInEclipseButton.addSelectionListener(this.defaultListener); | ||
} | ||
|
||
/** | ||
* Loads the launch options from the launch configuration's preference store. | ||
* | ||
* @param config the config to load the agent name from | ||
*/ | ||
protected void updateLaunchOptionsFromConfig(ILaunchConfiguration config) { | ||
final boolean runInEclipse = this.accessor.isEmbeddedSRE(config); | ||
final boolean enableAssertionsRun = this.accessor.isAssertionEnabledInRunMode(config); | ||
final boolean enableAssertionsDebug = this.accessor.isAssertionEnabledInDebugMode(config); | ||
this.enableAssertionsInRunModeButton.setSelection(enableAssertionsRun); | ||
this.enableAssertionsInDebugModeButton.setSelection(enableAssertionsDebug); | ||
this.runInEclipseButton.setSelection(runInEclipse); | ||
} | ||
|
||
@Override | ||
public void initializeFrom(ILaunchConfiguration config) { | ||
super.initializeFrom(config); | ||
updateLaunchOptionsFromConfig(config); | ||
} | ||
|
||
@Override | ||
public void performApply(ILaunchConfigurationWorkingCopy config) { | ||
this.configurator.setAssertionEnabledInRunMode(config, this.enableAssertionsInRunModeButton.getSelection()); | ||
this.configurator.setAssertionEnabledInDebugMode(config, this.enableAssertionsInDebugModeButton.getSelection()); | ||
this.configurator.setEmbeddedSRE(config, this.runInEclipseButton.getSelection()); | ||
super.performApply(config); | ||
} | ||
|
||
/** Listener of events in internal components for refreshing the tab. | ||
* | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
* @since 0.7 | ||
*/ | ||
private class WidgetListener implements SelectionListener { | ||
|
||
WidgetListener() { | ||
// | ||
} | ||
|
||
@Override | ||
public void widgetDefaultSelected(SelectionEvent event) { | ||
// | ||
} | ||
|
||
@SuppressWarnings("synthetic-access") | ||
@Override | ||
public void widgetSelected(SelectionEvent event) { | ||
updateLaunchConfigurationDialog(); | ||
} | ||
|
||
} | ||
|
||
} |
77 changes: 77 additions & 0 deletions
77
...ipse/src/io/sarl/eclipse/launching/runner/SARLApplicationLaunchConfigurationDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* $Id$ | ||
* | ||
* SARL is an general-purpose agent programming language. | ||
* More details on http://www.sarl.io | ||
* | ||
* Copyright (C) 2014-2018 the original authors or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.sarl.eclipse.launching.runner; | ||
|
||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.debug.core.ILaunch; | ||
import org.eclipse.debug.core.ILaunchConfiguration; | ||
|
||
import io.sarl.eclipse.runtime.ISREInstall; | ||
|
||
/** | ||
* Implementation of an eclipse LauncConfigurationDelegate to launch SARL application. | ||
* | ||
* <p>This delegate is in charge of running a SARL application with the specific | ||
* SRE. | ||
* | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
* @since 0.7 | ||
*/ | ||
public class SARLApplicationLaunchConfigurationDelegate extends AbstractSARLLaunchConfigurationDelegate { | ||
|
||
@Override | ||
protected ILaunchProcess createLaunchingProcess(ILaunchConfiguration configuration, String mode, ILaunch launch) { | ||
return new LaunchProcess(configuration, mode, launch); | ||
} | ||
|
||
@Override | ||
protected String getProgramArguments(ILaunchConfiguration configuration, ISREInstall sre, | ||
String standardProgramArguments) throws CoreException { | ||
return standardProgramArguments; | ||
} | ||
|
||
/** Definition of the launching process, split in separated steps for | ||
* making easier the cancellation. | ||
* | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
* @sincec 0.7 | ||
*/ | ||
private class LaunchProcess extends AbstractLaunchProcess { | ||
|
||
/** Constructor. | ||
* @param configuration the launch configuration. | ||
* @param mode the launching mode. | ||
* @param launch the launching | ||
*/ | ||
LaunchProcess(ILaunchConfiguration configuration, String mode, ILaunch launch) { | ||
super(configuration, mode, launch); | ||
} | ||
|
||
} | ||
|
||
} |