Commit 3808262a authored by Adam Knapp's avatar Adam Knapp
Browse files

Some UX improvements



Simplified error message: An error occured while -> Error while
During run config edit, automatic filling of config file by selecting
the project
Relative config file path in run config for better portability
Filtered list of projects in project selection dialog according to the
run config type

Change-Id: I5754648ed443d20ecc1688163e149f7e11750254
Signed-off-by: default avatarAdam Knapp <adam.knapp@sigmatechnology.se>
parent e0db3251
......@@ -16,6 +16,13 @@
namespace="org.eclipse.titan.executor.propertyTesters" properties="SingleModeBuild, ParallelModeBuild"
type="org.eclipse.core.resources.IResource">
</propertyTester>
<propertyTester
class="org.eclipse.titan.designer.properties.propertytesters.TitanBuilderEnabled"
id="org.eclipse.titan.designer.properties.TitanBuilderTester"
namespace="org.eclipse.titan.designer.properties.TitanBuilder"
properties="isTitanBuilder, isTitanJavaBuilder"
type="java.lang.Object">
</propertyTester>
</extension>
<extension point="org.eclipse.debug.core.launchConfigurationTypes">
<launchConfigurationType name="TITAN Parallel launcher"
......@@ -59,6 +66,8 @@
<test
property="org.eclipse.titan.executor.propertyTesters.SingleModeBuild"
forcePluginActivation="true" />
<test
property="org.eclipse.titan.designer.properties.TitanBuilder.isTitanBuilder" />
</iterate>
</with>
</enablement>
......@@ -89,6 +98,8 @@
<test
property="org.eclipse.titan.executor.propertyTesters.SingleModeBuild"
forcePluginActivation="true" />
<test
property="org.eclipse.titan.designer.properties.TitanBuilder.isTitanBuilder" />
</iterate>
</with>
</enablement>
......@@ -116,6 +127,8 @@
<test
property="org.eclipse.titan.executor.propertyTesters.ParallelModeBuild"
forcePluginActivation="true" />
<test
property="org.eclipse.titan.designer.properties.TitanBuilder.isTitanBuilder" />
</iterate>
</with>
</enablement>
......@@ -146,6 +159,8 @@
<test
property="org.eclipse.titan.executor.propertyTesters.ParallelModeBuild"
forcePluginActivation="true" />
<test
property="org.eclipse.titan.designer.properties.TitanBuilder.isTitanBuilder" />
</iterate>
</with>
</enablement>
......@@ -172,6 +187,8 @@
<test
property="org.eclipse.titan.executor.propertyTesters.ParallelModeBuild"
forcePluginActivation="true" />
<test
property="org.eclipse.titan.designer.properties.TitanBuilder.isTitanBuilder" />
</iterate>
</with>
</enablement>
......@@ -179,31 +196,6 @@
<configurationType
id="org.eclipse.titan.executor.executors.jni.LaunchConfigurationDelegate" />
</shortcut>
<shortcut class="org.eclipse.titan.executor.executors.java_mctr.LaunchShortcut"
id="org.eclipse.titan.executor.executors.java_mctr.LaunchShortcut"
label="TITAN Native Java launcher" icon="icons/launch_jni.gif"
description="Launch an execution in native Java mode" modes="run">
<description description="Runs a local TITAN application"
mode="run">
</description>
<contextualLaunch>
<enablement>
<with variable="selection">
<count value="1" />
<iterate>
<instanceof value="org.eclipse.core.resources.IProject" />
<test value="org.eclipse.titan.designer.core.TITANNature"
property="org.eclipse.core.resources.projectNature" />
<test
property="org.eclipse.titan.executor.propertyTesters.ParallelModeBuild"
forcePluginActivation="true" />
</iterate>
</with>
</enablement>
</contextualLaunch>
<configurationType
id="org.eclipse.titan.executor.executors.java_mctr.LaunchConfigurationDelegate" />
</shortcut>
<shortcut
class="org.eclipse.titan.executor.executors.jni.LaunchShortcutConfig"
description="Launch an execution in jni mode" icon="icons/launch_jni.gif"
......@@ -227,6 +219,8 @@
<test
property="org.eclipse.titan.executor.propertyTesters.ParallelModeBuild"
forcePluginActivation="true" />
<test
property="org.eclipse.titan.designer.properties.TitanBuilder.isTitanBuilder" />
</iterate>
</with>
</enablement>
......@@ -235,6 +229,33 @@
id="org.eclipse.titan.executor.executors.jni.LaunchConfigurationDelegate">
</configurationType>
</shortcut>
<shortcut class="org.eclipse.titan.executor.executors.java_mctr.LaunchShortcut"
id="org.eclipse.titan.executor.executors.java_mctr.LaunchShortcut"
label="TITAN Native Java launcher" icon="icons/launch_jni.gif"
description="Launch an execution in native Java mode" modes="run">
<description description="Runs a local TITAN application"
mode="run">
</description>
<contextualLaunch>
<enablement>
<with variable="selection">
<count value="1" />
<iterate operator="and">
<instanceof value="org.eclipse.core.resources.IProject" />
<test value="org.eclipse.titan.designer.core.TITANNature"
property="org.eclipse.core.resources.projectNature" />
<test
property="org.eclipse.titan.executor.propertyTesters.ParallelModeBuild"
forcePluginActivation="true" />
<test
property="org.eclipse.titan.designer.properties.TitanBuilder.isTitanJavaBuilder" />
</iterate>
</with>
</enablement>
</contextualLaunch>
<configurationType
id="org.eclipse.titan.executor.executors.java_mctr.LaunchConfigurationDelegate" />
</shortcut>
<shortcut
class="org.eclipse.titan.executor.executors.java_mctr.LaunchShortcutConfig"
description="Launch an execution in native Java mode" icon="icons/launch_jni.gif"
......@@ -258,6 +279,8 @@
<test
property="org.eclipse.titan.executor.propertyTesters.ParallelModeBuild"
forcePluginActivation="true" />
<test
property="org.eclipse.titan.designer.properties.TitanBuilder.isTitanJavaBuilder" />
</iterate>
</with>
</enablement>
......
......@@ -27,6 +27,7 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.titan.common.logging.ErrorReporter;
import org.eclipse.titan.common.path.PathUtil;
import org.eclipse.titan.designer.properties.data.ProjectFileHandler;
import org.eclipse.titan.executor.tabpages.hostcontrollers.HostControllersTab;
import org.eclipse.ui.IEditorPart;
......@@ -38,10 +39,29 @@ import org.eclipse.ui.dialogs.ElementListSelectionDialog;
* If this is a new launch configuration it is saved with a temporal name, if something with the same selection input can be found it is reused.
*
* @author Kristof Szabados
* @author Adam Knapp
* */
public abstract class LaunchShortcut implements ILaunchShortcut {
/**
* Returns the configuration ID, e.g.
* org.eclipse.titan.executor.executors.single.LaunchConfigurationDelegate
* @return Configuration ID
*/
protected abstract String getConfigurationId();
/**
* Returns the title string for the dialog
* @return Title of dialog
*/
protected abstract String getDialogTitle();
/**
* Returns the launch configuration type:
* Single, Parallel, Parallel-JNI, Parallel-Java
* @return Type of launch configuration
*/
protected abstract String getLaunchConfigurationType();
/**
* Initializes the provided launch configuration for execution.
......@@ -101,7 +121,9 @@ public abstract class LaunchShortcut implements ILaunchShortcut {
labelProvider.dispose();
}
final String configurationName = "new configuration (" + file.getFullPath().toString().replace("/", "__") + ")";
final String configurationName = file.getFullPath().toString().substring(1).replace("/", "-")
+ "-" + getLaunchConfigurationType();
final ILaunchConfigurationWorkingCopy wc = configurationType.newInstance(null, configurationName);
wc.setMappedResources(new IResource[] {project});
wc.setAttribute(EXECUTECONFIGFILEONLAUNCH, true);
......@@ -153,7 +175,7 @@ public abstract class LaunchShortcut implements ILaunchShortcut {
} else {
ErrorReporter.logError("Config file not found");
ErrorReporter.parallelErrorDisplayInMessageDialog(
"An error was found while creating the default launch configuration for project "
"Error while creating the default launch configuration for project "
+ project.getName(),
"Config file not found in project " + project.getName());
return;
......@@ -171,7 +193,8 @@ public abstract class LaunchShortcut implements ILaunchShortcut {
return; // successful launch happened
}
boolean result = initLaunchConfiguration(wc, project, cfgFile.getLocation().toOSString());
boolean result = initLaunchConfiguration(wc, project,
PathUtil.getRelativePath(project.getLocation().toOSString(), cfgFile.getLocation().toOSString()));
if (result) {
result = HostControllersTab.initLaunchConfiguration(wc);
}
......
......@@ -27,6 +27,7 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.titan.common.logging.ErrorReporter;
import org.eclipse.titan.common.path.PathUtil;
import org.eclipse.titan.executor.tabpages.hostcontrollers.HostControllersTab;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
......@@ -37,10 +38,29 @@ import org.eclipse.ui.dialogs.ElementListSelectionDialog;
* If this is a new launch configuration it is saved with a temporal name, if something with the same selection input can be found it is reused.
*
* @author Kristof Szabados
* @author Adam Knapp
* */
public abstract class LaunchShortcutConfig implements ILaunchShortcut {
/**
* Returns the configuration ID, e.g.
* org.eclipse.titan.executor.executors.single.LaunchConfigurationDelegate
* @return Configuration ID
*/
protected abstract String getConfigurationId();
/**
* Returns the title string for the dialog
* @return Title of dialog
*/
protected abstract String getDialogTitle();
/**
* Returns the launch configuration type:
* Single, Parallel, Parallel-JNI, Parallel-Java
* @return Type of launch configuration
*/
protected abstract String getLaunchConfigurationType();
/**
* Initializes the provided launch configuration for execution.
......@@ -100,7 +120,8 @@ public abstract class LaunchShortcutConfig implements ILaunchShortcut {
labelProvider.dispose();
}
// size() == 0 case: create new configuration
final String configurationName = "new configuration (" + file.getFullPath().toString().replace("/", "__") + ")";
final String configurationName = file.getFullPath().toString().substring(1).replace("/", "-")
+ "-" + getLaunchConfigurationType();
final ILaunchConfigurationWorkingCopy wc = configurationType.newInstance(null, configurationName);
wc.setMappedResources(new IResource[] {project, file});
wc.setAttribute(EXECUTECONFIGFILEONLAUNCH, true);
......@@ -145,12 +166,13 @@ public abstract class LaunchShortcutConfig implements ILaunchShortcut {
return;
}
try {
final ILaunchConfigurationWorkingCopy wc = getWorkingCopy(project,file, mode);
final ILaunchConfigurationWorkingCopy wc = getWorkingCopy(project, file, mode);
if (wc == null) {
return; //successful launch
}
boolean result = initLaunchConfiguration(wc, project, file.getLocation().toOSString());
boolean result = initLaunchConfiguration(wc, project,
PathUtil.getRelativePath(project.getLocation().toOSString(), file.getLocation().toOSString()));
if (result) {
result = HostControllersTab.initLaunchConfiguration(wc);
}
......
......@@ -27,6 +27,12 @@ public final class LaunchShortcut extends org.eclipse.titan.executor.executors.L
protected String getDialogTitle() {
return "Select (parallel) native Java mode execution configuration";
}
@Override
/** {@inheritDoc} */
protected String getLaunchConfigurationType() {
return "Parallel-Java";
}
@Override
/** {@inheritDoc} */
......
......@@ -26,6 +26,12 @@ public final class LaunchShortcutConfig extends org.eclipse.titan.executor.execu
protected String getDialogTitle() {
return "Select native Java mode execution";
}
@Override
/** {@inheritDoc} */
protected String getLaunchConfigurationType() {
return "Parallel-Java";
}
@Override
/** {@inheritDoc} */
......
......@@ -552,14 +552,14 @@ public class NativeJavaExecutor extends BaseExecutor {
if (configHandler == null) {
ErrorReporter.parallelErrorDisplayInMessageDialog(
"An error was found while processing the configuration file",
"Error while processing the configuration file",
"Please refer to the Error Log view for further information.");
return;
} else if (configHandler.isErroneous()) {
if (configHandler.parseExceptions().isEmpty()) {
ErrorReporter.parallelErrorDisplayInMessageDialog(
"An error was found while processing the configuration file",
"Error while processing the configuration file",
"Please refer to the Error Log view for further information.");
} else {
final Throwable exception = configHandler.parseExceptions().get(configHandler.parseExceptions().size() - 1);
......
......@@ -525,14 +525,14 @@ public final class JniExecutor extends BaseExecutor implements IJNICallback {
if (configHandler == null) {
ErrorReporter.parallelErrorDisplayInMessageDialog(
"An error was found while processing the configuration file",
"Error while processing the configuration file",
"Please refer to the Error Log view for further information.");
return;
} else if( configHandler.isErroneous() ) {
if (configHandler.parseExceptions().isEmpty()) {
ErrorReporter.parallelErrorDisplayInMessageDialog(
"An error was found while processing the configuration file",
"Error while processing the configuration file",
"Please refer to the Error Log view for further information.");
} else {
final Throwable exception = configHandler.parseExceptions().get(configHandler.parseExceptions().size() - 1);
......
......@@ -27,6 +27,12 @@ public final class LaunchShortcut extends org.eclipse.titan.executor.executors.L
protected String getDialogTitle() {
return "Select (parallel) jni mode execution configuration";
}
@Override
/** {@inheritDoc} */
protected String getLaunchConfigurationType() {
return "Parallel-JNI";
}
@Override
/** {@inheritDoc} */
......
......@@ -26,6 +26,12 @@ public final class LaunchShortcutConfig extends org.eclipse.titan.executor.execu
protected String getDialogTitle() {
return "Select jni mode execution";
}
@Override
/** {@inheritDoc} */
protected String getLaunchConfigurationType() {
return "Parallel-JNI";
}
@Override
/** {@inheritDoc} */
......
......@@ -360,14 +360,14 @@ public final class CliExecutor extends BaseExecutor {
configHandler = readConfigFile();
if (configHandler == null) {
ErrorReporter.parallelErrorDisplayInMessageDialog(
"An error was found while processing the configuration file",
"Error while processing the configuration file",
"Please refer to the Error Log view for further information.");
return true;
} else if( configHandler.isErroneous() ) {
if (configHandler.parseExceptions().isEmpty()) {
ErrorReporter.parallelErrorDisplayInMessageDialog(
"An error was found while processing the configuration file",
"Error while processing the configuration file",
"Please refer to the Error Log view for further information.");
} else {
final Throwable exception = configHandler.parseExceptions().get(configHandler.parseExceptions().size() - 1);
......
......@@ -13,6 +13,7 @@ import org.eclipse.titan.executor.tabpages.maincontroller.MctrCliMainControllerT
/**
* @author Kristof Szabados
* @author Adam Knapp
* */
public final class LaunchShortcut extends org.eclipse.titan.executor.executors.LaunchShortcut {
@Override
......@@ -26,6 +27,12 @@ public final class LaunchShortcut extends org.eclipse.titan.executor.executors.L
protected String getDialogTitle() {
return "Select (parallel) mctr_cli mode execution configuration";
}
@Override
/** {@inheritDoc} */
protected String getLaunchConfigurationType() {
return "Parallel";
}
@Override
/** {@inheritDoc} */
......
......@@ -26,6 +26,12 @@ public final class LaunchShortcutConfig extends org.eclipse.titan.executor.execu
protected String getDialogTitle() {
return "Select mctr_cli mode execution";
}
@Override
/** {@inheritDoc} */
protected String getLaunchConfigurationType() {
return "Parallel";
}
@Override
/** {@inheritDoc} */
......
......@@ -13,6 +13,7 @@ import org.eclipse.titan.executor.tabpages.maincontroller.SingleMainControllerTa
/**
* @author Kristof Szabados
* @author Adam Knapp
* */
public final class LaunchShortcut extends org.eclipse.titan.executor.executors.LaunchShortcut {
......@@ -27,6 +28,12 @@ public final class LaunchShortcut extends org.eclipse.titan.executor.executors.L
protected String getDialogTitle() {
return "Select single mode execution configuration";
}
@Override
/** {@inheritDoc} */
protected String getLaunchConfigurationType() {
return "Single";
}
@Override
/** {@inheritDoc} */
......
......@@ -26,6 +26,12 @@ public final class LaunchShortcutConfig extends org.eclipse.titan.executor.execu
protected String getDialogTitle() {
return "Select single mode execution";
}
@Override
/** {@inheritDoc} */
protected String getLaunchConfigurationType() {
return "Single";
}
@Override
/** {@inheritDoc} */
......
......@@ -174,7 +174,7 @@ public final class SingleExecutor extends BaseExecutor {
if (configHandler.parseExceptions().isEmpty()) {
ErrorReporter.parallelErrorDisplayInMessageDialog(
"An error was found while processing the configuration file",
"Error while processing the configuration file",
"Please refer to the Error Log view for further information.");
} else {
final Throwable exception = configHandler.parseExceptions().get(configHandler.parseExceptions().size() - 1);
......
......@@ -26,6 +26,7 @@ import java.util.Map;
import java.util.regex.Pattern;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
......@@ -35,6 +36,7 @@ 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.debug.ui.DebugUITools;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.debug.ui.ILaunchConfigurationTabGroup;
import org.eclipse.jface.viewers.ILabelProvider;
......@@ -59,6 +61,8 @@ import org.eclipse.titan.common.parsers.cfg.ConfigFileHandler;
import org.eclipse.titan.common.path.PathConverter;
import org.eclipse.titan.common.path.TITANPathUtilities;
import org.eclipse.titan.common.utils.IOUtils;
import org.eclipse.titan.designer.core.TITANBuilder;
import org.eclipse.titan.designer.properties.data.ProjectFileHandler;
import org.eclipse.titan.executor.TITANConsole;
import org.eclipse.titan.executor.TITANDebugConsole;
import org.eclipse.titan.executor.designerconnection.DesignerHelper;
......@@ -365,18 +369,27 @@ public abstract class BaseMainControllerTab extends AbstractLaunchConfigurationT
final ILabelProvider labelProvider = new WorkbenchLabelProvider();
final ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
dialog.setTitle("Project selection");
dialog.setMessage("Select a project to constrain your search.");
dialog.setMessage("Assign a project to the run configuration");
final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
final List<IProject> availableProjects = new ArrayList<IProject>(projects.length);
for (final IProject project : projects) {
try {
if (project.isAccessible() && project.hasNature(DesignerHelper.NATURE_ID)) {
if (project.isAccessible() && project.hasNature(DesignerHelper.NATURE_ID)
&& TITANBuilder.isBuilderEnabled(project)) {
availableProjects.add(project);
}
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
if (availableProjects.isEmpty()) {
ErrorReporter.parallelErrorDisplayInMessageDialog(
"Error while searching for projects in the workspace",
"No proper project was found in the workspace for this run configuration type");
return;
}
dialog.setElements(availableProjects.toArray(new IProject[availableProjects.size()]));
if (dialog.open() == Window.OK) {
final String projectName = ((IProject) dialog.getFirstResult()).getName();
......@@ -410,11 +423,32 @@ public abstract class BaseMainControllerTab extends AbstractLaunchConfigurationT
}
projectIsValid = true;
final String projectPath = project.getLocation().toOSString();
workingdirectoryText.setRootPath(projectPath);
executableFileText.setRootPath(projectPath);
configurationFileText.setRootPath(projectPath);
workingdirectoryText.setStringValue(getRAWWorkingDirectoryForProject(project));
final String executable = getExecutableForProject(project);
if (executable != null) {
executableFileText.setStringValue(executable);
}
final List<IFile> cfgFiles = ProjectFileHandler.getCfgFiles(project);
if (cfgFiles.size() == 1) {
configurationFileText.setStringValue(cfgFiles.get(0).getProjectRelativePath().toOSString());
} else if (cfgFiles.size() > 1) {
final ILabelProvider labelProvider = DebugUITools.newDebugModelPresentation();
final ElementListSelectionDialog dialog = new ElementListSelectionDialog(null, labelProvider);
dialog.setTitle("Config File Selection");
dialog.setMessage("Select existing cfg file:");
dialog.setElements(cfgFiles.toArray(new IFile[cfgFiles.size()]));
if (dialog.open() == Window.OK) {
configurationFileText.setStringValue(
((IFile) dialog.getFirstResult()).getProjectRelativePath().toOSString());
}
}
}
protected final void handleWorkingDirectoryModified() {
......@@ -673,7 +707,7 @@ public abstract class BaseMainControllerTab extends AbstractLaunchConfigurationT
public static String getRAWWorkingDirectoryForProject(final IProject project) {
try {
final String workingDirectory = project.getPersistentProperty(
new QualifiedName(DesignerHelper.PROJECT_BUILD_PROPERTYPAGE_QUALIFIER, DesignerHelper.WORKINGDIR_PROPERTY));
new QualifiedName(DesignerHelper.PROJECT_BUILD_PROPERTYPAGE_QUALIFIER, DesignerHelper.WORKINGDIR_PROPERTY));
return workingDirectory;
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
......@@ -762,7 +796,7 @@ public abstract class BaseMainControllerTab extends AbstractLaunchConfigurationT
final String workingDirectory = getRAWWorkingDirectoryForProject(project);
if (isNullOrEmpty(workingDirectory)) {
ErrorReporter.parallelErrorDisplayInMessageDialog(
"An error was found while creating the default launch configuration for project " + project.getName(),
"Error while creating the default launch configuration for project " + project.getName(),
"The working directory must be set.");
return false;
}
......@@ -771,13 +805,13 @@ public abstract class BaseMainControllerTab extends AbstractLaunchConfigurationT
File file = new File(uri);
if (!file.exists()) {
ErrorReporter.parallelErrorDisplayInMessageDialog(
"An error was found while creating the default launch configuration for project " + project.getName(),
"Error while creating the default launch configuration for project " + project.getName(),
"The working directory does not exist.");
return false;
}
if (!file.isDirectory()) {
ErrorReporter.parallelErrorDisplayInMessageDialog(
"An error was found while creating the default launch configuration for project " + project.getName(),
"Error while creating the default launch configuration for project " + project.getName(),
"The path set as working directory does not point to a folder.");
return false;
}
......@@ -791,19 +825,19 @@ public abstract class BaseMainControllerTab extends AbstractLaunchConfigurationT
helper = ExecutableCalculationHelper.checkExecutable(configuration, project, uri2);