summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Aubry2012-10-02 09:40:25 (EDT)
committerKevin KIN-FOO2012-10-02 11:57:10 (EDT)
commite6f501f0ba2bdd2ed91206da469792ce1df5ec64 (patch)
treedcceba55db4891dfea0d5fa3384f28dbc1d95716
parent60c0f0a4dd3531e9fde54740d29d691c136e79df (diff)
downloadorg.eclipse.koneki.ldt-e6f501f0ba2bdd2ed91206da469792ce1df5ec64.zip
org.eclipse.koneki.ldt-e6f501f0ba2bdd2ed91206da469792ce1df5ec64.tar.gz
org.eclipse.koneki.ldt-e6f501f0ba2bdd2ed91206da469792ce1df5ec64.tar.bz2
bug 390674: [remote] Remote launch configuration, UI part
-rw-r--r--plugins/org.eclipse.koneki.ldt.debug.core/META-INF/MANIFEST.MF6
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.core/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/LuaRemoteDebugConstant.java5
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationDelegate.java3
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationUtil.java15
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/Messages.java3
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/messages.properties3
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.ui/META-INF/MANIFEST.MF14
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.ui/OSGI-INF/l10n/bundle.properties3
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.ui/plugin.xml3
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteEnvironmentTab.java424
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationMainTab.java220
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationTabGroup.java5
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/Messages.java7
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/messages.properties2
-rw-r--r--plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/LuaDialogUtil.java53
-rw-r--r--target-platform/ldt.target58
17 files changed, 716 insertions, 112 deletions
diff --git a/plugins/org.eclipse.koneki.ldt.debug.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.koneki.ldt.debug.core/META-INF/MANIFEST.MF
index 84d2761..f22a4bc 100644
--- a/plugins/org.eclipse.koneki.ldt.debug.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.koneki.ldt.debug.core/META-INF/MANIFEST.MF
@@ -13,7 +13,7 @@ Require-Bundle: org.eclipse.core.runtime,
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.eclipse.koneki.ldt.debug.core.internal;x-friends:="org.eclipse.koneki.ldt.debug.ui,org.eclipse.koneki.ldt.remote.debug.core",
- org.eclipse.koneki.ldt.debug.core.internal.attach;x-internal:=true,
- org.eclipse.koneki.ldt.debug.core.internal.interpreter.generic;x-friends:="org.eclipse.koneki.ldt.support.lua51",
- org.eclipse.koneki.ldt.debug.core.internal.local;x-internal:=true
+ org.eclipse.koneki.ldt.debug.core.internal.attach;x-friends:="org.eclipse.koneki.ldt.remote.debug.core",
+ org.eclipse.koneki.ldt.debug.core.internal.interpreter.generic;x-friends:="org.eclipse.koneki.ldt.support.lua51,org.eclipse.debug.core",
+ org.eclipse.koneki.ldt.debug.core.internal.local;x-friends:="org.eclipse.debug.core"
Bundle-Vendor: %Bundle-Vendor
diff --git a/plugins/org.eclipse.koneki.ldt.remote.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.koneki.ldt.remote.core/META-INF/MANIFEST.MF
index bdc8cee..a625ffb 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.koneki.ldt.remote.core/META-INF/MANIFEST.MF
@@ -18,5 +18,5 @@ Require-Bundle: org.eclipse.core.runtime,
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: %Bundle-Vendor
-Export-Package: org.eclipse.koneki.ldt.remote.core.internal;x-friends:="org.eclipse.koneki.ldt.remote.ui,org.eclipse.koneki.ldt.remote.debug.core",
- org.eclipse.koneki.ldt.remote.core.internal.lua;x-friends:="org.eclipse.koneki.ldt.remote.ui,org.eclipse.koneki.ldt.remote.debug.core"
+Export-Package: org.eclipse.koneki.ldt.remote.core.internal;x-friends:="org.eclipse.koneki.ldt.remote.ui,org.eclipse.koneki.ldt.remote.debug.core,org.eclipse.koneki.ldt.remote.debug.ui",
+ org.eclipse.koneki.ldt.remote.core.internal.lua;x-friends:="org.eclipse.koneki.ldt.remote.ui,org.eclipse.koneki.ldt.remote.debug.core, org.eclipse.koneki.ldt.remote.debug.ui"
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/LuaRemoteDebugConstant.java b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/LuaRemoteDebugConstant.java
index 26a3979..9ab05a7 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/LuaRemoteDebugConstant.java
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/LuaRemoteDebugConstant.java
@@ -14,7 +14,10 @@ import org.eclipse.dltk.launching.ScriptLaunchConfigurationConstants;
public interface LuaRemoteDebugConstant {
- String HOST_ID = Activator.PLUGIN_ID + ".debug.hostid"; //$NON-NLS-1$
String PROJECT_NAME = ScriptLaunchConfigurationConstants.ATTR_PROJECT_NAME;
+ String SCRIPT_NAME = ScriptLaunchConfigurationConstants.ATTR_MAIN_SCRIPT_NAME;
+ String HOST_ID = Activator.PLUGIN_ID + ".debug.hostid"; //$NON-NLS-1$
+ String BREAK_ON_FIRST_LINE = ScriptLaunchConfigurationConstants.ENABLE_BREAK_ON_FIRST_LINE;
+ String DBGP_LOGGING = ScriptLaunchConfigurationConstants.ENABLE_DBGP_LOGGING;
}
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationDelegate.java b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationDelegate.java
index 9fb192f..bfffef3 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationDelegate.java
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationDelegate.java
@@ -78,12 +78,13 @@ public class LuaRemoteLaunchConfigurationDelegate extends LaunchConfigurationDel
// get configuration information
String projectName = configuration.getAttribute(LuaRemoteDebugConstant.PROJECT_NAME, "");//$NON-NLS-1$
+ String scriptName = configuration.getAttribute(LuaRemoteDebugConstant.SCRIPT_NAME, "");//$NON-NLS-1$
IHost host = LuaRemoteLaunchConfigurationUtil.getHost(configuration);
@SuppressWarnings("rawtypes")
Map env = configuration.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, Collections.EMPTY_MAP);
// valid configuration information
- String errorMessage = LuaRemoteLaunchConfigurationUtil.validateRemoteLaunchConfiguration(projectName, host);
+ String errorMessage = LuaRemoteLaunchConfigurationUtil.validateRemoteLaunchConfiguration(projectName, scriptName, host);
if (errorMessage != null)
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, errorMessage));
submonitor.worked(1);
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationUtil.java b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationUtil.java
index f7d3471..ab520d5 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationUtil.java
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationUtil.java
@@ -15,6 +15,7 @@ import java.util.Collections;
import java.util.List;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -98,7 +99,7 @@ public final class LuaRemoteLaunchConfigurationUtil {
*
* @return true if value is valid
*/
- public static String validateRemoteLaunchConfiguration(String projectName, IHost host) {
+ public static String validateRemoteLaunchConfiguration(String projectName, String scriptName, IHost host) {
// project validation
// -------------------------------
// projectName validation
@@ -121,6 +122,18 @@ public final class LuaRemoteLaunchConfigurationUtil {
return "Unexpected problem :" + e.getMessage(); //$NON-NLS-1$
}
+ // scriptName validation
+ if (scriptName == null || scriptName.isEmpty()) {
+ return Messages.LuaRemoteLaunchConfigurationUtil_error_no_script_selected;
+ }
+ IResource script = project.findMember(scriptName);
+ if (script == null || !script.exists()) {
+ return NLS.bind(Messages.LuaRemoteLaunchConfigurationUtil_error_script_desnt_exist, scriptName);
+ }
+ if (script.getType() != IResource.FILE || !script.getFileExtension().equals("lua")) { //$NON-NLS-1$
+ return NLS.bind(Messages.LuaRemoteLaunchConfigurationUtil_error_script_not_lua_file, scriptName);
+ }
+
// target validation
// --------------------------------
if (host == null) {
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/Messages.java b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/Messages.java
index 9c28343..c0c6252 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/Messages.java
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/Messages.java
@@ -29,7 +29,10 @@ public class Messages extends NLS {
public static String LuaRemoteLaunchConfigurationUtil_error_no_outputdir;
public static String LuaRemoteLaunchConfigurationUtil_error_no_project;
public static String LuaRemoteLaunchConfigurationUtil_error_no_remote_file_service;
+ public static String LuaRemoteLaunchConfigurationUtil_error_no_script_selected;
public static String LuaRemoteLaunchConfigurationUtil_error_not_lua_project;
+ public static String LuaRemoteLaunchConfigurationUtil_error_script_desnt_exist;
+ public static String LuaRemoteLaunchConfigurationUtil_error_script_not_lua_file;
public static String LuaRemoteLaunchConfigurationUtil_error_unexisted_project;
static {
// initialize resource bundle
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/messages.properties b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/messages.properties
index 1a1fec6..80cbe1c 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/messages.properties
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/messages.properties
@@ -14,3 +14,6 @@ LuaRemoteLaunchConfigurationUtil_error_no_lua_service=The host ''{0}'' has no lu
LuaRemoteLaunchConfigurationUtil_error_no_luacommand=The Lua Service is badly configured for host ''{0}'' : Lua command should not be empty
LuaRemoteLaunchConfigurationUtil_error_no_outputdir=The Lua Service is badly configured for host ''{0}'' : Output directory should not be empty
LuaRemoteLaunchConfigurationUtil_error_no_remote_file_service=The host ''{0}'' has no remote file service.
+LuaRemoteLaunchConfigurationUtil_error_no_script_selected=A script must be selected
+LuaRemoteLaunchConfigurationUtil_error_script_desnt_exist=The script doesn't exsist: {0}
+LuaRemoteLaunchConfigurationUtil_error_script_not_lua_file=The script is not a lua file: {0}
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/META-INF/MANIFEST.MF
index a2796d3..12bbf74 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/META-INF/MANIFEST.MF
@@ -6,12 +6,14 @@ Bundle-Version: 0.9.0.qualifier
Bundle-Activator: org.eclipse.koneki.ldt.remote.debug.ui.internal.Activator
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.debug.ui,
- org.eclipse.koneki.ldt.ui;bundle-version="0.9.0",
- org.eclipse.ui;bundle-version="3.103.0",
- org.eclipse.koneki.ldt.remote.debug.core;bundle-version="0.9.0",
- org.eclipse.dltk.launching;bundle-version="4.0.0",
- org.eclipse.rse.ui;bundle-version="3.3.0",
- org.eclipse.rse.core;bundle-version="3.3.0"
+ org.eclipse.koneki.ldt.ui,
+ org.eclipse.ui,
+ org.eclipse.koneki.ldt.remote.debug.core,
+ org.eclipse.rse.ui,
+ org.eclipse.rse.core,
+ org.eclipse.dltk.debug.ui,
+ org.eclipse.koneki.ldt,
+ org.eclipse.koneki.ldt.remote.core
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: %Bundle-Vendor
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/OSGI-INF/l10n/bundle.properties b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/OSGI-INF/l10n/bundle.properties
index 53d537a..7ef8e4f 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/OSGI-INF/l10n/bundle.properties
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/OSGI-INF/l10n/bundle.properties
@@ -1,3 +1,4 @@
#Properties file for org.eclipse.koneki.ldt.remote.debug.ui
Bundle-Name = LDT Remote Development Support Debug UI (Incubation)
-Bundle-Vendor = Eclipse Koneki \ No newline at end of file
+Bundle-Vendor = Eclipse Koneki
+org.eclipse.koneki.ldt.remote.debug.ui.internal.launch.tab.description = Launch Lua Application on Remote Target \ No newline at end of file
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/plugin.xml b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/plugin.xml
index 8f715b1..322ee62 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/plugin.xml
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/plugin.xml
@@ -6,7 +6,8 @@
<launchConfigurationTabGroup
class="org.eclipse.koneki.ldt.remote.debug.ui.internal.launch.tab.LuaRemoteLaunchConfigurationTabGroup"
id="org.eclipse.koneki.ldt.remote.debug.ui.luaRemoteApplicationLaunchTabGroup"
- type="org.eclipse.koneki.ldt.remote.debug.core.luaremotedebug">
+ type="org.eclipse.koneki.ldt.remote.debug.core.luaremotedebug"
+ description="%org.eclipse.koneki.ldt.remote.debug.ui.internal.launch.tab.description">
<launchMode
mode="debug"
perspective="org.eclipse.debug.ui.DebugPerspective">
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteEnvironmentTab.java b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteEnvironmentTab.java
new file mode 100644
index 0000000..5163577
--- /dev/null
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteEnvironmentTab.java
@@ -0,0 +1,424 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Sierra Wireless and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sierra Wireless - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.koneki.ldt.remote.debug.ui.internal.launch.tab;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.internal.ui.DebugPluginImages;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.MultipleInputDialog;
+import org.eclipse.debug.internal.ui.launchConfigurations.EnvironmentVariable;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsMessages;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.ScrollBar;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+/**
+ * A more Simple EnvironmentTab then the official one
+ *
+ * @see org.eclipse.debug.ui.EnvironmentTab
+ */
+@SuppressWarnings("restriction")
+public class LuaRemoteEnvironmentTab extends AbstractLaunchConfigurationTab {
+
+ private static final String NAME_LABEL = LaunchConfigurationsMessages.EnvironmentTab_8;
+ private static final String VALUE_LABEL = LaunchConfigurationsMessages.EnvironmentTab_9;
+
+ private String[] envTableColumnHeaders = { LaunchConfigurationsMessages.EnvironmentTab_Variable_1,
+ LaunchConfigurationsMessages.EnvironmentTab_Value_2, };
+
+ private TableViewer environmentTable;
+ private Button envAddButton;
+ private Button envEditButton;
+ private Button envRemoveButton;
+
+ protected static class EnvironmentVariableContentProvider implements IStructuredContentProvider {
+ @SuppressWarnings("rawtypes")
+ public Object[] getElements(Object inputElement) {
+ List<EnvironmentVariable> elements = new ArrayList<EnvironmentVariable>();
+ ILaunchConfiguration config = (ILaunchConfiguration) inputElement;
+ Map m;
+ try {
+ m = config.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, Collections.EMPTY_MAP);
+ } catch (CoreException e) {
+ DebugUIPlugin.log(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, "Error reading configuration", e)); //$NON-NLS-1$
+ return elements.toArray();
+ }
+ if (m != null && !m.isEmpty()) {
+ for (Object oEntry : m.entrySet()) {
+ Entry entry = (Entry) oEntry;
+ elements.add(new EnvironmentVariable((String) entry.getKey(), (String) entry.getValue()));
+ }
+ }
+ return elements.toArray();
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ if (newInput == null) {
+ return;
+ }
+ if (viewer instanceof TableViewer) {
+ TableViewer tableViewer = (TableViewer) viewer;
+ if (tableViewer.getTable().isDisposed()) {
+ return;
+ }
+ tableViewer.setComparator(new ViewerComparator() {
+ public int compare(Viewer iviewer, Object e1, Object e2) {
+ if (e1 == null) {
+ return -1;
+ } else if (e2 == null) {
+ return 1;
+ } else {
+ return ((EnvironmentVariable) e1).getName().compareToIgnoreCase(((EnvironmentVariable) e2).getName());
+ }
+ }
+ });
+ }
+ }
+ }
+
+ /**
+ * Label provider for the environment table
+ */
+ public static class EnvironmentVariableLabelProvider extends LabelProvider implements ITableLabelProvider {
+ public String getColumnText(Object element, int columnIndex) {
+ String result = null;
+ if (element != null) {
+ EnvironmentVariable var = (EnvironmentVariable) element;
+ switch (columnIndex) {
+ case 0: // variable
+ result = var.getName();
+ break;
+ case 1: // value
+ result = var.getValue();
+ break;
+ default:
+ result = ""; //$NON-NLS-1$
+ break;
+ }
+ }
+ return result;
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ if (columnIndex == 0) {
+ return DebugPluginImages.getImage(IDebugUIConstants.IMG_OBJS_ENV_VAR);
+ }
+ return null;
+ }
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createControl(Composite parent) {
+ Composite comp = new Composite(parent, SWT.NONE);
+ setControl(comp);
+ GridLayoutFactory.swtDefaults().numColumns(2).applyTo(comp);
+ comp.setFont(parent.getFont());
+
+ createEnvironmentTable(comp);
+ createTableButtons(comp);
+ }
+
+ /**
+ * @param mainComposite
+ */
+ private void createTableButtons(Composite parent) {
+ // Create button composite
+ Composite buttonComposite = new Composite(parent, SWT.NONE);
+ GridLayoutFactory.swtDefaults().applyTo(buttonComposite);
+ GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).applyTo(buttonComposite);
+
+ // Create buttons
+ envAddButton = createPushButton(buttonComposite, LaunchConfigurationsMessages.EnvironmentTab_New_4, null);
+ envAddButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ handleEnvAddButtonSelected();
+ }
+ });
+ envEditButton = createPushButton(buttonComposite, LaunchConfigurationsMessages.EnvironmentTab_Edit_5, null);
+ envEditButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ handleEnvEditButtonSelected();
+ }
+ });
+ envEditButton.setEnabled(false);
+ envRemoveButton = createPushButton(buttonComposite, LaunchConfigurationsMessages.EnvironmentTab_Remove_6, null);
+ envRemoveButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ handleEnvRemoveButtonSelected();
+ }
+ });
+ envRemoveButton.setEnabled(false);
+ }
+
+ /**
+ * @param mainComposite
+ */
+ private void createEnvironmentTable(Composite parent) {
+ // Create label, add it to the parent to align the right side buttons with the top of the table
+ Label l = new Label(parent, SWT.NONE);
+ l.setText(LaunchConfigurationsMessages.EnvironmentTab_Environment_variables_to_set__3);
+ GridDataFactory.swtDefaults().span(2, 1).applyTo(l);
+
+ // Create table composite
+ Composite tableComposite = new Composite(parent, SWT.NONE);
+ GridLayoutFactory.fillDefaults().applyTo(tableComposite);
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(tableComposite);
+
+ // Create table
+ environmentTable = new TableViewer(tableComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
+ Table table = environmentTable.getTable();
+ GridLayoutFactory.swtDefaults().applyTo(table);
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(table);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ environmentTable.setContentProvider(new EnvironmentVariableContentProvider());
+ environmentTable.setLabelProvider(new EnvironmentVariableLabelProvider());
+ environmentTable.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleTableSelectionChanged(event);
+ }
+ });
+ environmentTable.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ if (!environmentTable.getSelection().isEmpty()) {
+ handleEnvEditButtonSelected();
+ }
+ }
+ });
+
+ // Create columns
+ final TableColumn tc1 = new TableColumn(table, SWT.NONE, 0);
+ tc1.setText(envTableColumnHeaders[0]);
+ final TableColumn tc2 = new TableColumn(table, SWT.NONE, 1);
+ tc2.setText(envTableColumnHeaders[1]);
+ final Table tref = table;
+ final Composite comp = tableComposite;
+ tableComposite.addControlListener(new ControlAdapter() {
+ public void controlResized(ControlEvent e) {
+ Rectangle area = comp.getClientArea();
+ Point size = tref.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ ScrollBar vBar = tref.getVerticalBar();
+ int width = area.width - tref.computeTrim(0, 0, 0, 0).width - 2;
+ if (size.y > area.height + tref.getHeaderHeight()) {
+ Point vBarSize = vBar.getSize();
+ width -= vBarSize.x;
+ }
+ Point oldSize = tref.getSize();
+ if (oldSize.x > area.width) {
+ tc1.setWidth(width / 2 - 1);
+ tc2.setWidth(width - tc1.getWidth());
+ tref.setSize(area.width, area.height);
+ } else {
+ tref.setSize(area.width, area.height);
+ tc1.setWidth(width / 2 - 1);
+ tc2.setWidth(width - tc1.getWidth());
+ }
+ }
+ });
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ @Override
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ @Override
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ environmentTable.setInput(configuration);
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ @Override
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ // Convert the table's items into a Map so that this can be saved in the
+ // configuration's attributes.
+ TableItem[] items = environmentTable.getTable().getItems();
+ Map<String, String> map = new HashMap<String, String>(items.length);
+ for (int i = 0; i < items.length; i++) {
+ EnvironmentVariable var = (EnvironmentVariable) items[i].getData();
+ map.put(var.getName(), var.getValue());
+ }
+ if (map.size() == 0) {
+ configuration.removeAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES);
+ } else {
+ configuration.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, map);
+ }
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
+ */
+ @Override
+ public String getName() {
+ return LaunchConfigurationsMessages.EnvironmentTab_Environment_7;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
+ */
+ public Image getImage() {
+ return DebugPluginImages.getImage(IDebugUIConstants.IMG_OBJS_ENVIRONMENT);
+ }
+
+ /**
+ * Responds to a selection changed event in the environment table
+ *
+ * @param event
+ * the selection change event
+ */
+ protected void handleTableSelectionChanged(SelectionChangedEvent event) {
+ int size = ((IStructuredSelection) event.getSelection()).size();
+ envEditButton.setEnabled(size == 1);
+ envRemoveButton.setEnabled(size > 0);
+ }
+
+ protected void handleEnvRemoveButtonSelected() {
+ IStructuredSelection sel = (IStructuredSelection) environmentTable.getSelection();
+ environmentTable.getControl().setRedraw(false);
+ for (Iterator<?> i = sel.iterator(); i.hasNext();) {
+ EnvironmentVariable var = (EnvironmentVariable) i.next();
+ environmentTable.remove(var);
+ }
+ environmentTable.getControl().setRedraw(true);
+ updateLaunchConfigurationDialog();
+ }
+
+ protected void handleEnvAddButtonSelected() {
+ MultipleInputDialog dialog = new MultipleInputDialog(getShell(), LaunchConfigurationsMessages.EnvironmentTab_22);
+ dialog.addTextField(NAME_LABEL, null, false);
+ dialog.addTextField(VALUE_LABEL, null, false);
+
+ if (dialog.open() != Window.OK) {
+ return;
+ }
+
+ String name = dialog.getStringValue(NAME_LABEL);
+ String value = dialog.getStringValue(VALUE_LABEL);
+
+ if (name != null && value != null && name.length() > 0 && value.length() > 0) {
+ addVariable(new EnvironmentVariable(name.trim(), value.trim()));
+ }
+ }
+
+ /**
+ * Attempts to add the given variable. Returns whether the variable was added or not (as when the user answers not to overwrite an existing
+ * variable).
+ *
+ * @param variable
+ * the variable to add
+ * @return whether the variable was added
+ */
+ protected boolean addVariable(EnvironmentVariable variable) {
+ String name = variable.getName();
+ TableItem[] items = environmentTable.getTable().getItems();
+ for (int i = 0; i < items.length; i++) {
+ EnvironmentVariable existingVariable = (EnvironmentVariable) items[i].getData();
+ if (existingVariable.getName().equals(name)) {
+ boolean overWrite = MessageDialog.openQuestion(getShell(), LaunchConfigurationsMessages.EnvironmentTab_12,
+ MessageFormat.format(LaunchConfigurationsMessages.EnvironmentTab_13, new Object[] { name })); //
+ if (!overWrite) {
+ return false;
+ }
+ environmentTable.remove(existingVariable);
+ break;
+ }
+ }
+ environmentTable.add(variable);
+ updateLaunchConfigurationDialog();
+ return true;
+ }
+
+ protected void handleEnvEditButtonSelected() {
+ IStructuredSelection sel = (IStructuredSelection) environmentTable.getSelection();
+ EnvironmentVariable var = (EnvironmentVariable) sel.getFirstElement();
+ if (var == null) {
+ return;
+ }
+ String originalName = var.getName();
+ String value = var.getValue();
+ MultipleInputDialog dialog = new MultipleInputDialog(getShell(), LaunchConfigurationsMessages.EnvironmentTab_11);
+ dialog.addTextField(NAME_LABEL, originalName, false);
+ dialog.addTextField(VALUE_LABEL, value, false);
+
+ if (dialog.open() != Window.OK) {
+ return;
+ }
+ String name = dialog.getStringValue(NAME_LABEL);
+ value = dialog.getStringValue(VALUE_LABEL);
+ if (!originalName.equals(name)) {
+ if (addVariable(new EnvironmentVariable(name, value))) {
+ environmentTable.remove(var);
+ }
+ } else {
+ var.setValue(value);
+ environmentTable.update(var, null);
+ updateLaunchConfigurationDialog();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationMainTab.java b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationMainTab.java
index 4365432..16269af 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationMainTab.java
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationMainTab.java
@@ -10,14 +10,22 @@
*******************************************************************************/
package org.eclipse.koneki.ldt.remote.debug.ui.internal.launch.tab;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
-import org.eclipse.dltk.launching.ScriptLaunchConfigurationConstants;
+import org.eclipse.dltk.debug.ui.preferences.ScriptDebugPreferencesMessages;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.koneki.ldt.core.LuaConstants;
+import org.eclipse.koneki.ldt.core.LuaNature;
+import org.eclipse.koneki.ldt.remote.core.internal.RSEUtil;
import org.eclipse.koneki.ldt.remote.debug.core.internal.LuaRemoteDebugConstant;
import org.eclipse.koneki.ldt.remote.debug.core.internal.launch.LuaRemoteLaunchConfigurationUtil;
import org.eclipse.koneki.ldt.remote.debug.ui.internal.Activator;
@@ -32,6 +40,7 @@ import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
@@ -51,12 +60,31 @@ public class LuaRemoteLaunchConfigurationMainTab extends AbstractLaunchConfigura
}
}
- // private Text luacpathText;
- // private Text luapathText;
+ /**
+ * Commons listener for UI (used to update dialog buttons)
+ */
+ private final class SelectionChangeListener extends SelectionAdapter {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ updateLaunchConfigurationDialog();
+ }
+ }
+
private SystemHostCombo hostCombo;
private TextModifyListener textModifyListener = new TextModifyListener();
+ private SelectionListener selectionChangeListener = new SelectionChangeListener();
private Text projectNameText;
private Button projectSelectionButton;
+ private Text scriptNameText;
+ private Button scriptSelectionButton;
+ private Button breakOnFirstLineButton;
+ private Button enableLoggingButton;
+
+ private String mode;
+
+ public LuaRemoteLaunchConfigurationMainTab(String mode) {
+ this.mode = mode;
+ }
/**
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
@@ -69,16 +97,15 @@ public class LuaRemoteLaunchConfigurationMainTab extends AbstractLaunchConfigura
comp.setFont(parent.getFont());
// TODO not sure this is the good way to wait for init everywhere in the code
- try {
- RSECorePlugin.waitForInitCompletion();
- // CHECKSTYLE:OFF
- } catch (InterruptedException e) {
- // nothing to do ..
- // CHECKSTYLE:ON
- }
+ RSEUtil.waitForRSEInitialization();
createProjectConfigComponent(comp);
+ createScriptConfigComponent(comp);
createTargetConfigComponent(comp);
+
+ if (ILaunchManager.DEBUG_MODE.equals(mode)) {
+ createDebugConfigComponent(comp);
+ }
}
/**
@@ -100,6 +127,23 @@ public class LuaRemoteLaunchConfigurationMainTab extends AbstractLaunchConfigura
projectSelectionButton.setText(Messages.LuaRemoteMainTab_projectgroup_browseprojectbutton);
final int browseButtonHorizontalHint = SWTUtil.getButtonWidthHint(projectSelectionButton);
GridDataFactory.fillDefaults().align(SWT.END, SWT.BEGINNING).hint(browseButtonHorizontalHint, SWT.DEFAULT).applyTo(projectSelectionButton);
+
+ }
+
+ private void createScriptConfigComponent(Composite comp) {
+ // create group
+ Group group = new Group(comp, SWT.None);
+ group.setText(Messages.LuaRemoteLaunchConfigurationMainTab_scriptgroup_title);
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(group);
+ GridLayoutFactory.swtDefaults().numColumns(2).applyTo(group);
+
+ // create script choice :
+ scriptNameText = new Text(group, SWT.SINGLE | SWT.BORDER);
+ GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(scriptNameText);
+ scriptSelectionButton = new Button(group, SWT.PUSH);
+ scriptSelectionButton.setText(Messages.LuaRemoteMainTab_projectgroup_browseprojectbutton);
+ final int browseButtonHorizontalHint = SWTUtil.getButtonWidthHint(projectSelectionButton);
+ GridDataFactory.fillDefaults().align(SWT.END, SWT.BEGINNING).hint(browseButtonHorizontalHint, SWT.DEFAULT).applyTo(scriptSelectionButton);
}
/**
@@ -119,32 +163,24 @@ public class LuaRemoteLaunchConfigurationMainTab extends AbstractLaunchConfigura
hostCombo = new SystemHostCombo(group, SWT.None, selectfirstHost, true, "files", false); //$NON-NLS-1$
final int newSystemHint = SWTUtil.getButtonWidthHint(hostCombo.getNewButton());
hostCombo.setButtonWidthHint(newSystemHint);
-
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(hostCombo);
+ }
- // create interpreter command :
- // Label luacommandLabel = new Label(group, SWT.None);
- // luacommandLabel.setText(Messages.LuaEmbeddedMainTab_targetgroup_luacommandlabel);
- // luaCommandPathText = new Text(group, SWT.SINGLE | SWT.BORDER);
- // GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(luaCommandPathText);
-
- // // create luapath
- // Label luapathLabel = new Label(group, SWT.None);
- // luapathLabel.setText(Messages.LuaEmbeddedMainTab_targetgroup_luapathlabel);
- // luapathText = new Text(group, SWT.SINGLE | SWT.BORDER);
- // GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(luapathText);
- //
- // // create luacpath
- // Label luacpathLabel = new Label(group, SWT.None);
- // luacpathLabel.setText(Messages.LuaEmbeddedMainTab_targetgroup_luacpathlabel);
- // luacpathText = new Text(group, SWT.SINGLE | SWT.BORDER);
- // GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(luacpathText);
-
- // create remote path
- // Label ramoteApplicationPathLabel = new Label(group, SWT.None);
- // ramoteApplicationPathLabel.setText(Messages.LuaEmbeddedMainTab_targetgroup_remoteapppathlabel);
- // remoteApplicationPathText = new Text(group, SWT.SINGLE | SWT.BORDER);
- // GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(remoteApplicationPathText);
+ /**
+ * @param comp
+ */
+ private void createDebugConfigComponent(Composite comp) {
+ // create group
+ Group group = new Group(comp, SWT.None);
+ group.setText(Messages.LuaRemoteLaunchConfigurationMainTab_debuggroup_title);
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(group);
+ GridLayoutFactory.swtDefaults().numColumns(2).applyTo(group);
+
+ breakOnFirstLineButton = createCheckButton(group, ScriptDebugPreferencesMessages.BreakOnFirstLineLabel);
+ createVerticalSpacer(group, 1);
+
+ enableLoggingButton = createCheckButton(group, ScriptDebugPreferencesMessages.EnableDbgpLoggingLabel);
+ createVerticalSpacer(group, 1);
}
/**
@@ -152,17 +188,40 @@ public class LuaRemoteLaunchConfigurationMainTab extends AbstractLaunchConfigura
*/
@Override
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
- // TODO : get project of selected resource
- configuration.setAttribute(ScriptLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
- // get first available target
- // IHost[] hosts = RSECorePlugin.getTheSystemRegistry().getHosts();
- // if (hosts.length > 0) {
- // LuaRemoteLaunchConfigurationUtil.setConnectionId(configuration, hosts[0]);
- // }
+ IProject defaultProject = null;
+ try {
+ IProject[] avilableProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for (IProject project : avilableProjects) {
+ if (project.hasNature(LuaNature.ID) && defaultProject == null) {
+ defaultProject = project;
+ }
+ }
+ // CHECKSTYLE:OFF
+ } catch (CoreException e) {
+ // nothing to do, continue trying to find a default project
+ }
+ // CHECKSTYLE:ON
+
+ configuration.setAttribute(LuaRemoteDebugConstant.PROJECT_NAME, defaultProject == null ? "" : defaultProject.getName()); //$NON-NLS-1$
- // TODO integrate UI, see org.eclipse.dltk.debug.ui.launchConfigurations.ScriptLaunchConfigurationTab
- configuration.setAttribute(ScriptLaunchConfigurationConstants.ENABLE_DBGP_LOGGING, false);
+ String defaultScript = ""; //$NON-NLS-1$
+ if (defaultProject != null) {
+ IPath standardPath = new Path(LuaConstants.SOURCE_FOLDER).append(LuaConstants.DEFAULT_MAIN_FILE);
+ IFile standardFile = defaultProject.getFile(standardPath);
+ if (standardFile.exists()) {
+ defaultScript = standardFile.getProjectRelativePath().toPortableString();
+ }
+ }
+ configuration.setAttribute(LuaRemoteDebugConstant.SCRIPT_NAME, defaultScript);
+
+ // get first available target
+ IHost[] hosts = RSECorePlugin.getTheSystemRegistry().getHosts();
+ if (hosts.length > 0) {
+ LuaRemoteLaunchConfigurationUtil.setConnectionId(configuration, hosts[0]);
+ }
+ configuration.setAttribute(LuaRemoteDebugConstant.DBGP_LOGGING, false);
+ configuration.setAttribute(LuaRemoteDebugConstant.BREAK_ON_FIRST_LINE, false);
}
/**
@@ -171,6 +230,8 @@ public class LuaRemoteLaunchConfigurationMainTab extends AbstractLaunchConfigura
private void addListeners() {
if (!projectNameText.isListening(SWT.Modify))
projectNameText.addModifyListener(textModifyListener);
+ if (!scriptNameText.isListening(SWT.Modify))
+ scriptNameText.addModifyListener(textModifyListener);
if (!projectSelectionButton.isListening(SWT.Selection))
projectSelectionButton.addSelectionListener(new SelectionAdapter() {
@Override
@@ -178,17 +239,19 @@ public class LuaRemoteLaunchConfigurationMainTab extends AbstractLaunchConfigura
selectLuaEmbeddedProject();
}
});
- // if (!luapathText.isListening(SWT.Modify))
- // luapathText.addModifyListener(textModifyListener);
- // if (!luacpathText.isListening(SWT.Modify))
- // luacpathText.addModifyListener(textModifyListener);
- if (!hostCombo.isListening(SWT.Selection))
- hostCombo.addSelectionListener(new SelectionAdapter() {
+ if (!scriptSelectionButton.isListening(SWT.Selection))
+ scriptSelectionButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- updateLaunchConfigurationDialog();
+ selectScript();
}
});
+ if (!hostCombo.isListening(SWT.Selection))
+ hostCombo.addSelectionListener(selectionChangeListener);
+ if (breakOnFirstLineButton != null && !breakOnFirstLineButton.isListening(SWT.Selection))
+ breakOnFirstLineButton.addSelectionListener(selectionChangeListener);
+ if (enableLoggingButton != null && !enableLoggingButton.isListening(SWT.Selection))
+ enableLoggingButton.addSelectionListener(selectionChangeListener);
}
/**
@@ -197,12 +260,25 @@ public class LuaRemoteLaunchConfigurationMainTab extends AbstractLaunchConfigura
@Override
public void initializeFrom(ILaunchConfiguration configuration) {
try {
- String projectName = configuration.getAttribute(ScriptLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
+ String projectName = configuration.getAttribute(LuaRemoteDebugConstant.PROJECT_NAME, ""); //$NON-NLS-1$
if (!projectName.equals(projectNameText.getText()))
projectNameText.setText(projectName);
+ String scriptName = configuration.getAttribute(LuaRemoteDebugConstant.SCRIPT_NAME, ""); //$NON-NLS-1$
+ if (!scriptName.equals(scriptNameText.getText()))
+ scriptNameText.setText(scriptName);
IHost host = LuaRemoteLaunchConfigurationUtil.getHost(configuration);
if (hostCombo.getHost() != host)
hostCombo.select(host);
+
+ if (breakOnFirstLineButton != null) {
+ boolean breakOnFirstLine = configuration.getAttribute(LuaRemoteDebugConstant.BREAK_ON_FIRST_LINE, false);
+ breakOnFirstLineButton.setSelection(breakOnFirstLine);
+ }
+ if (enableLoggingButton != null) {
+ boolean enableDBGPLogging = configuration.getAttribute(LuaRemoteDebugConstant.DBGP_LOGGING, false);
+ enableLoggingButton.setSelection(enableDBGPLogging);
+ }
+
addListeners();
} catch (CoreException e) {
Activator.logError("Launch Configuration main tab for lua embedded failed at initialization", e); //$NON-NLS-1$
@@ -215,12 +291,19 @@ public class LuaRemoteLaunchConfigurationMainTab extends AbstractLaunchConfigura
@Override
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
// Save attributes
- configuration.setAttribute(ScriptLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectNameText.getText());
+ configuration.setAttribute(LuaRemoteDebugConstant.PROJECT_NAME, projectNameText.getText());
+ configuration.setAttribute(LuaRemoteDebugConstant.SCRIPT_NAME, scriptNameText.getText());
IHost host = hostCombo.getHost();
if (host != null)
LuaRemoteLaunchConfigurationUtil.setConnectionId(configuration, hostCombo.getHost());
else
configuration.removeAttribute(LuaRemoteDebugConstant.HOST_ID);
+ if (breakOnFirstLineButton != null) {
+ configuration.setAttribute(LuaRemoteDebugConstant.BREAK_ON_FIRST_LINE, breakOnFirstLineButton.getSelection());
+ }
+ if (enableLoggingButton != null) {
+ configuration.setAttribute(LuaRemoteDebugConstant.DBGP_LOGGING, enableLoggingButton.getSelection());
+ }
}
/**
@@ -244,16 +327,13 @@ public class LuaRemoteLaunchConfigurationMainTab extends AbstractLaunchConfigura
*/
@Override
public boolean isValid(ILaunchConfiguration configuration) {
- // try {
- // String projectName = configuration.getAttribute(ScriptLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");//$NON-NLS-1$
+ // String projectName = configuration.getAttribute(LuaRemoteDebugConstant.PROJECT_NAME, "");//$NON-NLS-1$
+ // String scriptName = configuration.getAttribute(LuaRemoteDebugConstant.SCRIPT_NAME, ""); //$NON-NLS-1$
// IHost host = LuaRemoteLaunchConfigurationUtil.getHost(configuration);
- // return innerIsValuesValid(projectName, host, luacommandpath, remoteapplicationpath);
- // return false;
- // } catch (CoreException e) {
- // Activator.logError("Launch Configuration main tab for lua embedded failed at validation", e); //$NON-NLS-1$
- // return false;
- // }
- return true;
+ String projectName = projectNameText.getText();
+ String scriptName = scriptNameText.getText();
+ IHost host = hostCombo.getHost();
+ return innerIsValuesValid(projectName, scriptName, host);
}
/**
@@ -262,8 +342,9 @@ public class LuaRemoteLaunchConfigurationMainTab extends AbstractLaunchConfigura
@Override
public boolean canSave() {
String projectName = projectNameText.getText();
+ String scriptName = scriptNameText.getText();
IHost host = hostCombo.getHost();
- return innerIsValuesValid(projectName, host);
+ return innerIsValuesValid(projectName, scriptName, host);
}
/**
@@ -273,8 +354,8 @@ public class LuaRemoteLaunchConfigurationMainTab extends AbstractLaunchConfigura
*
* @return true if value is valid
*/
- private boolean innerIsValuesValid(String projectName, IHost host) {
- String error = LuaRemoteLaunchConfigurationUtil.validateRemoteLaunchConfiguration(projectName, host);
+ private boolean innerIsValuesValid(String projectName, String scriptName, IHost host) {
+ String error = LuaRemoteLaunchConfigurationUtil.validateRemoteLaunchConfiguration(projectName, scriptName, host);
setErrorMessage(error);
return error == null;
}
@@ -289,4 +370,15 @@ public class LuaRemoteLaunchConfigurationMainTab extends AbstractLaunchConfigura
projectNameText.setText(selectedProject.getName());
}
+ /**
+ * Open Script selection dialog
+ */
+ private void selectScript() {
+ String currentProjectName = projectNameText.getText();
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(currentProjectName);
+ IFile selectedScript = LuaDialogUtil.openSelectScriptFromProjectDialog(getShell(), project);
+ if (selectedScript != null && !selectedScript.getName().equals(scriptNameText.getText())) {
+ scriptNameText.setText(selectedScript.getProjectRelativePath().toPortableString());
+ }
+ }
}
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationTabGroup.java b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationTabGroup.java
index d187caa..1afacee 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationTabGroup.java
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationTabGroup.java
@@ -2,7 +2,6 @@ package org.eclipse.koneki.ldt.remote.debug.ui.internal.launch.tab;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
import org.eclipse.debug.ui.CommonTab;
-import org.eclipse.debug.ui.EnvironmentTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
@@ -14,8 +13,8 @@ public class LuaRemoteLaunchConfigurationTabGroup extends AbstractLaunchConfigur
@Override
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[3];
- tabs[0] = new LuaRemoteLaunchConfigurationMainTab();
- tabs[1] = new EnvironmentTab();
+ tabs[0] = new LuaRemoteLaunchConfigurationMainTab(mode);
+ tabs[1] = new LuaRemoteEnvironmentTab();
tabs[2] = new CommonTab();
setTabs(tabs);
}
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/Messages.java b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/Messages.java
index e64c410..81bb99e 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/Messages.java
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/Messages.java
@@ -14,12 +14,19 @@ import org.eclipse.osgi.util.NLS;
//CHECKSTYLE NLS: OFF
public class Messages extends NLS {
+
private static final String BUNDLE_NAME = "org.eclipse.koneki.ldt.remote.debug.ui.internal.launch.tab.messages"; //$NON-NLS-1$
+
+ public static String LuaRemoteLaunchConfigurationMainTab_debuggroup_title;
+
+ public static String LuaRemoteLaunchConfigurationMainTab_scriptgroup_title;
+
public static String LuaRemoteMainTab_projectgroup_browseprojectbutton;
public static String LuaRemoteMainTab_projectgroup_title;
public static String LuaRemoteMainTab_tabname;
public static String LuaRemoteMainTab_targetgroup_hostlabel;
public static String LuaRemoteMainTab_targetgroup_title;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/messages.properties b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/messages.properties
index bfe51b4..a9fd0e7 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/messages.properties
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/messages.properties
@@ -1,3 +1,5 @@
+LuaRemoteLaunchConfigurationMainTab_debuggroup_title=Debug Options
+LuaRemoteLaunchConfigurationMainTab_scriptgroup_title=Launch Script
LuaRemoteMainTab_projectgroup_browseprojectbutton=Bro&wse...
LuaRemoteMainTab_projectgroup_title=Project :
LuaRemoteMainTab_tabname=Main
diff --git a/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/LuaDialogUtil.java b/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/LuaDialogUtil.java
index 6755ba5..4e67ef4 100644
--- a/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/LuaDialogUtil.java
+++ b/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/LuaDialogUtil.java
@@ -10,10 +10,20 @@
*******************************************************************************/
package org.eclipse.koneki.ldt.ui;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.koneki.ldt.core.LuaUtils;
+import org.eclipse.koneki.ldt.ui.internal.Activator;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.model.WorkbenchLabelProvider;
@@ -26,13 +36,13 @@ public final class LuaDialogUtil {
}
public static final IProject openSelectLuaProjectDialog(Shell shell, String projectName) {
- // initialise selection dialog
+ // initialize selection dialog
ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new WorkbenchLabelProvider());
dialog.setTitle(Messages.LuaDialogUtil_title);
dialog.setMessage(Messages.LuaDialogUtil_message);
dialog.setElements(LuaUtils.getLuaProjects());
- // initialise default selected project
+ // initialize default selected project
if (projectName != null && !projectName.isEmpty()) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
if (project != null)
@@ -49,4 +59,43 @@ public final class LuaDialogUtil {
}
return null;
}
+
+ public static final IFile openSelectScriptFromProjectDialog(Shell shell, IProject project) {
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new WorkbenchLabelProvider());
+
+ dialog.setElements(getContainerScript(project, shell).toArray());
+ dialog.setMessage("Select a script file.");
+ dialog.setTitle("Select Script");
+ if (dialog.open() == Window.OK) {
+ return (IFile) dialog.getResult()[0];
+ }
+ return null;
+ }
+
+ private static List<IFile> getContainerScript(IContainer container, Shell shell) {
+ ArrayList<IFile> list = new ArrayList<IFile>();
+
+ try {
+ if (container.exists()) {
+ for (IResource child : container.members()) {
+
+ if (child instanceof IFile) {
+ IFile file = (IFile) child;
+ if (file.getName().endsWith(".lua")) //$NON-NLS-1$
+ list.add(file);
+ } else if (child instanceof IContainer) {
+ IContainer childContainer = (IContainer) child;
+ list.addAll(getContainerScript(childContainer, shell));
+ }
+ }
+ } else {
+ MessageDialog.openError(shell, "Unable to browse script", "The given project doesn't exist.");
+ }
+ } catch (CoreException e) {
+ String errorMessage = NLS.bind("Unable to find scripts files of {0}", container.getFullPath());
+ Activator.logError(errorMessage, e);
+ MessageDialog.openError(shell, "Unable to browse script", errorMessage);
+ }
+ return list;
+ }
}
diff --git a/target-platform/ldt.target b/target-platform/ldt.target
index 60c1a71..aa6882e 100644
--- a/target-platform/ldt.target
+++ b/target-platform/ldt.target
@@ -1,27 +1,31 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?pde version="3.6"?>
-
-<target name="Lua Development Tools" sequenceNumber="19">
-<locations>
-<location includeAllPlatforms="false" includeMode="planner" includeSource="false" type="InstallableUnit">
-<unit id="org.apache.commons.io" version="1.4.0.v20081110-1000"/>
-<unit id="org.apache.commons.io.source" version="1.4.0.v20081110-1000"/>
-<unit id="org.junit" version="4.8.1.v4_8_1_v20100427-1100"/>
-<unit id="org.junit.source" version="4.8.1.v4_8_1_v20100427-1100"/>
-<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/repository"/>
-</location>
-<location includeAllPlatforms="false" includeMode="planner" includeSource="false" type="InstallableUnit">
-<unit id="org.eclipse.platform.sdk" version="4.2.0.I20120608-1400"/>
-<repository location="http://download.eclipse.org/releases/juno"/>
-</location>
-<location includeAllPlatforms="false" includeMode="planner" includeSource="false" type="InstallableUnit">
-<unit id="org.eclipse.dltk.core.sdk.feature.group" version="4.0.0.201206120848"/>
-<unit id="org.eclipse.dltk.itcl.sdk.feature.group" version="4.0.0.201206120848"/>
-<unit id="org.eclipse.dltk.javascript.sdk.feature.group" version="4.0.0.201206120848"/>
-<unit id="org.eclipse.dltk.mylyn.sdk.feature.group" version="4.0.0.201206120848"/>
-<unit id="org.eclipse.dltk.python.sdk.feature.group" version="4.0.0.201206120848"/>
-<unit id="org.eclipse.dltk.tcl.sdk.feature.group" version="4.0.0.201206120848"/>
-<repository location="http://download.eclipse.org/technology/dltk/updates-dev/4.0-stable/"/>
-</location>
-</locations>
-</target> \ No newline at end of file
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?pde version="3.8"?>
+
+<target name="Lua Development Tools" sequenceNumber="20">
+<locations>
+<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="false" type="InstallableUnit">
+<unit id="org.apache.commons.io" version="1.4.0.v20081110-1000"/>
+<unit id="org.apache.commons.io.source" version="1.4.0.v20081110-1000"/>
+<unit id="org.junit" version="4.8.1.v4_8_1_v20100427-1100"/>
+<unit id="org.junit.source" version="4.8.1.v4_8_1_v20100427-1100"/>
+<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/repository"/>
+</location>
+<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="false" type="InstallableUnit">
+<unit id="org.eclipse.platform.sdk" version="4.2.0.I20120608-1400"/>
+<repository location="http://download.eclipse.org/releases/juno"/>
+</location>
+<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="false" type="InstallableUnit">
+<unit id="org.eclipse.dltk.core.sdk.feature.group" version="4.0.0.201206120848"/>
+<unit id="org.eclipse.dltk.itcl.sdk.feature.group" version="4.0.0.201206120848"/>
+<unit id="org.eclipse.dltk.javascript.sdk.feature.group" version="4.0.0.201206120848"/>
+<unit id="org.eclipse.dltk.mylyn.sdk.feature.group" version="4.0.0.201206120848"/>
+<unit id="org.eclipse.dltk.python.sdk.feature.group" version="4.0.0.201206120848"/>
+<unit id="org.eclipse.dltk.tcl.sdk.feature.group" version="4.0.0.201206120848"/>
+<repository location="http://download.eclipse.org/technology/dltk/updates-dev/4.0-stable/"/>
+</location>
+<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="false" type="InstallableUnit">
+<unit id="org.eclipse.rse.sdk.feature.group" version="3.4.0.201205300905-7U7UFBV7lfbwaIHTQX71hXj27ViO"/>
+<repository location="http://download.eclipse.org/tm/updates/3.4/"/>
+</location>
+</locations>
+</target>