package edu.ncsu.muclipse.launch;
import mujava.MutationSystem;
import java.util.Vector;
import java.io.File;
import mujava.util.ExtensionFilter;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.internal.adaptor.EclipseStorageHook;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
//import org.eclipse.debug.internal.ui.SWTUtil;
import org.eclipse.osgi.framework.adaptor.FilePath;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.events.SelectionEvent;
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;
import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaModel;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaClasspathTab;
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaJRETab;
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaLaunchTab;
//import org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchConfigurationTab;
import org.eclipse.jdt.internal.ui.wizards.TypedElementSelectionValidator;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.ui.IJavaElementSearchConstants;
import org.eclipse.jdt.ui.ISharedImages;
import org.eclipse.jdt.ui.JavaElementLabelProvider;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Scrollable;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.eclipse.ui.dialogs.SelectionDialog;
import edu.ncsu.muclipse.FileLabelProvider;
import edu.ncsu.muclipse.FileTreeContentProvider;
import edu.ncsu.muclipse.FileViewerSorter;
import edu.ncsu.muclipse.MuClipseConstants;
import edu.ncsu.muclipse.MuClipsePlugin;
/**
* This is an Eclipse Runtime Configuration control
* for generating mutants. It gives the user options
* for which types of mutants to generate and which classes
* to generate them for.
*
* These options are turned into parameters in the class
* MutantsLaunchConfigType, which is what implements
* the Eclipse Runtime Configuration. The standard
* environment, classpath, JRE and source lookup tabs
* for a Java Runtime Configuration are also provided
* such that the user can better specify the context of
* his or her application.
*
* The following specific options are available in this
* runtime configuration group:
* <ul>
* <li>Resource pointers for directories containing:
* <ul>
* <li>.class objects</li>
* <li>.java sources</li>
* <li>.java/.class test cases</li>
* <li>Desired output folder</li>
* </ul></li>
* <li>Which project is being used</li>
* <li>A list of which mutation operators to use</li>
* <li>A list of which classes to mutate</li>
* </ul>
* @see MutantsLaunchConfigType
* @author Ben Smith
*/
public class MutantsLaunchConfigGroup extends
AbstractLaunchConfigurationTabGroup {
/**n
* The default constructor, which isn't used.
*/
public MutantsLaunchConfigGroup() {
}
/**
* This method is called from the Eclipse API; it
* provides a parent dialog control into which all
* the tabs (inner-classes) are placed.
*/
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
new MuClipseDirectories(),
new MuClipseMutants(),
new JavaClasspathTab(),
new JavaJRETab(),
new SourceLookupTab(),
new EnvironmentTab(),
new CommonTab()
};
setTabs(tabs);
}
private static class MuClipseDirectories extends
JavaLaunchTab {
Text txtProject;
Text txtOutput;
Text txtSelectedFolderClasses;
Text txtTargetClass;
// List classlist;
Text txtSelectedFolderSource;
// Group classes;
Button btnBrowseFolder;
private Button btnBrowseOutput;
public void createControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
setControl(comp);
GridLayout topLayout = new GridLayout();
topLayout.numColumns = 3;
comp.setLayout(topLayout);
insertEmpty(comp);
createProjectBlock(comp);
insertEmpty(comp);
createClassesFolderBlock(comp);
createSourceFolderBlock(comp);
insertEmpty(comp);
createClasses(comp);
Dialog.applyDialogFont(comp);
}
public Image getImage() {
return JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_EMPTY_PACKAGE);
}
static private void insertEmpty(Composite comp) {
Label label = new Label(comp, SWT.NONE);
setLayoutSpan(label, 3);
}
static private void setLayoutSpan(Control control, int span) {
GridData gd = new GridData();
gd.horizontalSpan = span;
control.setLayoutData(gd);
}
private static void setButtonGridData(Button button) {
GridData gridData= new GridData();
button.setLayoutData(gridData);
// SWTUtil.setButtonDimensionHint(button);
}
private static void setLayoutIndent(Control control, int indent) {
GridData gd = new GridData();
gd.horizontalIndent = indent;
control.setLayoutData(gd);
}
private void createClassesFolderBlock(Composite parent) {
Label lblFolder = new Label(parent, SWT.NONE);
lblFolder.setText("Classes Folder");
setLayoutIndent(lblFolder, 0);
txtSelectedFolderClasses = new Text(parent, SWT.SINGLE | SWT.BORDER);
txtSelectedFolderClasses.setLayoutData(
new GridData(GridData.FILL_HORIZONTAL));
txtSelectedFolderClasses.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent evt) {
validatePage();
}
});
btnBrowseFolder = new Button(parent, SWT.PUSH);
btnBrowseFolder.setText("Browse...");
setButtonGridData(btnBrowseFolder);
btnBrowseFolder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
browseFolderClicked(txtSelectedFolderClasses);
}
});
}
private void createSourceFolderBlock(Composite parent) {
Label lblFolder = new Label(parent, SWT.NONE);
lblFolder.setText(" ");
setLayoutIndent(lblFolder, 0);
txtSelectedFolderSource = new Text(parent, SWT.SINGLE | SWT.BORDER);
txtSelectedFolderSource.setLayoutData(
new GridData(GridData.FILL_HORIZONTAL));
txtSelectedFolderSource.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent evt) {
validatePage();
}
});
txtSelectedFolderSource.setVisible(false);
/**
btnBrowseFolder = new Button(parent, SWT.PUSH);
btnBrowseFolder.setText("Browse...");
setButtonGridData(btnBrowseFolder);
btnBrowseFolder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
browseFolderClicked(txtSelectedFolderSource);
}
});
**/
}
private void createProjectBlock(Composite parent) {
Label lblProject = new Label(parent, SWT.NONE);
lblProject.setText("Project");
txtProject = new Text(parent, SWT.SINGLE | SWT.BORDER);
txtProject.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
txtProject.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent evt) {
validatePage();
}
});
Button btnBrowseProject = new Button(parent, SWT.PUSH);
btnBrowseProject.setText("Browse...");
setButtonGridData(btnBrowseProject);
btnBrowseProject.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
browseProjectClicked();
}
});
Label lblOutput = new Label(parent, SWT.NONE);
lblOutput.setText("Mutants Output");
txtOutput = new Text(parent, SWT.SINGLE | SWT.BORDER);
txtOutput.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
txtOutput.setText("result/");
txtOutput.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent evt) {
validatePage();
}
});
btnBrowseOutput = new Button(parent, SWT.PUSH);
btnBrowseOutput.setText("Browse...");
setButtonGridData(btnBrowseOutput);
btnBrowseOutput.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
browseOutputClicked();
}
});
}
private void createClasses(Composite parent) {
Label lblFolder = new Label(parent, SWT.NONE);
lblFolder.setText("Class To Mutate");
setLayoutIndent(lblFolder, 0);
txtTargetClass = new Text(parent, SWT.SINGLE | SWT.BORDER);
txtTargetClass.setLayoutData(
new GridData(GridData.FILL_HORIZONTAL));
txtTargetClass.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent evt) {
validatePage();
}
});
btnBrowseFolder = new Button(parent, SWT.PUSH);
btnBrowseFolder.setText("Browse...");
setButtonGridData(btnBrowseFolder);
btnBrowseFolder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
browseFileClicked(txtTargetClass);
}
});
}
private boolean validateFolderExists(
String folderName, String errMessage) {
if(isEmptyString(folderName)) {
setErrorMessage(errMessage);
return false;
}
try{
IProject project =
MuClipsePlugin.getProject(txtProject.getText());
IFolder folder = project.getFolder(folderName);
if(!folder.exists()) {
setErrorMessage("Folder " + folderName + " does not exist");
return false;
}
return true;
} catch (IllegalArgumentException ignored) {
return false;
}
}
static private boolean isEmptyString(String string) {
return string == null || string.equals("");
}
private boolean validateProject(String projectName) {
if(isEmptyString(projectName)) {
setErrorMessage("Project does not exist!");
return false;
}
try {
IProject project = MuClipsePlugin.getProject(projectName);
if(!project.exists()) {
setErrorMessage(
"Project " + projectName + " does not exist");
return false;
}
return true;
} catch (IllegalArgumentException ignored) {
return false;
}
}
private void browseProjectClicked() {
IJavaProject selectedProject = chooseJavaProject();
if(selectedProject != null) {
txtProject.setText(selectedProject.getElementName());
}
}
private void browseOutputClicked() {
String folder = chooseFolder();
if(folder != null) {
txtOutput.setText(folder);
}
}
private void browseFolderClicked(Text boxToSet) {
String folder = chooseFolder();
if(folder != null) {
boxToSet.setText(folder);
}
}
private void browseFileClicked(Text boxToSet) {
// String file = chooseFiles();
String file = chooseClass();
if(file != null) {
boxToSet.setText(file);
}
}
private String chooseClass() {
IProject project = MuClipsePlugin.getProject(txtProject.getText().trim());
try
{
SelectionDialog dialog = JavaUI.createTypeDialog(getShell(), MuClipsePlugin.getWorkbenchWindow(),
project, IJavaElementSearchConstants.CONSIDER_CLASSES, false);
dialog.setTitle("MuClipse");
dialog.setMessage("Select java class to mutate");
if(dialog.open() == Window.OK) {
Object[] rc = dialog.getResult();
IType thisone = (IType) rc[0];
txtSelectedFolderSource.setText(thisone.getPath().segment(1));
return thisone.getPath().removeFirstSegments(2).toPortableString();
}
else
{
return "";
}
}
catch (JavaModelException jme)
{
jme.printStackTrace();
}
return "";
}
private String chooseFiles() {
IProject project = MuClipsePlugin.getProject(txtProject.getText().trim());
IFolder input = project.getFolder(txtSelectedFolderSource.getText());
final ElementTreeSelectionDialog dialog =
new ElementTreeSelectionDialog(getShell(),
new FileLabelProvider(),
new FileTreeContentProvider(false));
dialog.setAllowMultiple(true);
dialog.setTitle("MuClipse");
dialog.setMessage("Select a java class");
dialog.setInput(input);
dialog.setValidator(new TypedElementSelectionValidator(
new Class[]{IFile.class}, true));
if(dialog.open() == Window.OK) {
Object[] rc = dialog.getResult();
String toReturn = "";
for (int i=0;i<rc.length;i++)
{
IResource thisone = (IResource) rc[i];
toReturn += thisone.getFullPath()
.removeFirstSegments(2).toString() +
";";
}
return toReturn;
}
return null;
}
private String chooseFolder() {
IProject project = MuClipsePlugin.getProject(txtProject.getText().trim());
final ElementTreeSelectionDialog dialog =
new ElementTreeSelectionDialog(getShell(),
new FileLabelProvider(),
new FileTreeContentProvider(true));
dialog.setAllowMultiple(false);
dialog.setTitle("MuClipse");
dialog.setMessage("Select a folder");
dialog.setInput(project);
dialog.setValidator(new TypedElementSelectionValidator(
new Class[]{IFolder.class}, false));
if(dialog.open() == Window.OK) {
IResource rc = (IResource)dialog.getFirstResult();
if (rc != null)
return rc.getFullPath().removeFirstSegments(1).toString();
}
return null;
}
private IJavaProject chooseJavaProject() {
IJavaProject[] projects;
try {
projects = JavaCore.create(
MuClipsePlugin.getWorkspaceRoot()).getJavaProjects();
} catch (JavaModelException e) {
projects = new IJavaProject[0];
}
ILabelProvider labelProvider = new JavaElementLabelProvider(
JavaElementLabelProvider.SHOW_DEFAULT);
ElementListSelectionDialog dialog =
new ElementListSelectionDialog(getShell(), labelProvider);
dialog.setTitle("MuClipse");
dialog.setMessage("Select a Project");
dialog.setElements(projects);
IJavaProject javaProject = getJavaProject();
if (javaProject != null) {
dialog.setInitialSelections(new Object[] { javaProject });
}
if (dialog.open() == Window.OK) {
return (IJavaProject) dialog.getFirstResult();
}
return null;
}
private IJavaProject getJavaProject() {
String projectName = txtProject.getText().trim();
return MutantsLaunchConfigType.getJavaProject(projectName);
}
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
IJavaElement javaElement = getContext();
if (javaElement != null) {
initializeJavaProject(javaElement, configuration);
} else {
configuration.setAttribute(
IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
"");
}
configuration.setAttribute(
MuClipseConstants.MUTANTS,
MuClipseConstants.MUTANT_HOME);
configuration.setAttribute(
MuClipseConstants.TESTS,
MuClipseConstants.TESTSET_PATH);
configuration.setAttribute(
MuClipseConstants.CLASSES,
MuClipseConstants.CLASS_PATH);
configuration.setAttribute(
MuClipseConstants.SOURCE,
MuClipseConstants.SRC_PATH);
}
public void initializeFrom(ILaunchConfiguration configuration) {
try {
txtProject.setText(
configuration.getAttribute(
IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
""));
txtOutput.setText(
configuration.getAttribute(
MuClipseConstants.MUTANTS,
MuClipseConstants.MUTANT_HOME));
txtSelectedFolderClasses.setText(
configuration.getAttribute(
MuClipseConstants.CLASSES,
MuClipseConstants.CLASS_PATH));
txtSelectedFolderSource.setText(
configuration.getAttribute(
MuClipseConstants.SOURCE,
MuClipseConstants.SRC_PATH));
txtTargetClass.setText(
configuration.getAttribute(
MuClipseConstants.CLASSCHOICE,
""));
validatePage();
} catch (CoreException ignored) {
ignored.printStackTrace();
}
}
public void performApply(
ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(
IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
txtProject.getText());
configuration.setAttribute(
MuClipseConstants.MUTANTS,
txtOutput.getText());
configuration.setAttribute(
MuClipseConstants.CLASSES,
txtSelectedFolderClasses.getText());
configuration.setAttribute(
MuClipseConstants.SOURCE,
txtSelectedFolderSource.getText());
configuration.setAttribute(
MuClipseConstants.CLASSCHOICE,
txtTargetClass.getText());
}
private void validatePage() {
setMessage(null);
setErrorMessage(null);
setDirty(false);
// validateFolderExists(
// txtOutput.getText(),
// "Please specify an output folder");
if (isEmptyString(txtOutput.getText()))
setErrorMessage("Please specify an output folder");
validateFolderExists(
txtSelectedFolderClasses.getText(),
"Please specify a .classes folder");
validateFolderExists(
txtSelectedFolderSource.getText(),
"Please specify a source folder");
boolean projectSet = validateProject(txtProject.getText());
btnBrowseOutput.setEnabled(projectSet);
updateLaunchConfigurationDialog();
}
public String getName() {
return "Directories";
}
public boolean isValid(ILaunchConfiguration launchConfig) {
return getErrorMessage() == null;
}
}
private static class MuClipseMutants extends
JavaLaunchTab {
Button[] checklist_tm, checklist_cm;
/**
* @see MuClipseDirectories#createControl(Composite)
*/
public void createControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
setControl(comp);
GridLayout topLayout = new GridLayout();
topLayout.numColumns = 4;
comp.setLayout(topLayout);
createTraditionalChecklist(comp);
createClassLevelChecklist(comp);
createButtonGroup(comp);
Dialog.applyDialogFont(comp);
}
public Image getImage() {
return JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_CUNIT);
}
private void createTraditionalChecklist(Composite comp)
{
Group traditionalMutants = new Group(comp, SWT.SHADOW_ETCHED_IN);
GridLayout col = new GridLayout();
col.numColumns = 2;
setLayoutSpan(traditionalMutants, 1);
traditionalMutants.setLayout(col);
traditionalMutants.setText("Traditional Operators");
String[] data = MuClipseConstants.tm_operators;
checklist_tm = new Button[data.length];
for (int i=0; i<data.length; i++)
{
checklist_tm[i] = new Button(traditionalMutants, SWT.CHECK);
checklist_tm[i].setText(data[i]);
checklist_tm[i].addMouseListener(new MouseListener() {
public void mouseDown(MouseEvent e) {
}
public void mouseUp(MouseEvent e) {
validatePage();
}
public void mouseDoubleClick(MouseEvent e) {
}
});
}
for (int i=0; i<checklist_tm.length; i++)
checklist_tm[i].setSelection(true);
}
private void createClassLevelChecklist(Composite comp)
{
Group classMutants = new Group(comp, SWT.SHADOW_ETCHED_IN);
GridLayout col = new GridLayout();
col.numColumns = 3;
setLayoutSpan(classMutants, 1);
setTop(classMutants);
classMutants.setText("Class-Level Operators");
classMutants.setLayout(col);
String[] data = MuClipseConstants.cm_operators;
checklist_cm = new Button[data.length];
for (int i=0; i<data.length; i++)
{
checklist_cm[i] = new Button(classMutants, SWT.CHECK);
checklist_cm[i].setText(data[i]);
checklist_cm[i].addMouseListener(new MouseListener() {
public void mouseDown(MouseEvent e) {
}
public void mouseUp(MouseEvent e) {
validatePage();
}
public void mouseDoubleClick(MouseEvent e) {
}
});
}
for (int i=0; i<checklist_cm.length; i++)
checklist_cm[i].setSelection(true);
}
private void createButtonGroup(Composite comp)
{
Group quickSelect = new Group(comp, SWT.SHADOW_ETCHED_IN);
FillLayout col = new FillLayout(SWT.VERTICAL);
quickSelect.setLayout(col);
Button tradAll = new Button(quickSelect, SWT.PUSH);
tradAll.setText("All Traditional");
tradAll.addMouseListener(new MouseListener() {
public void mouseDown(MouseEvent e) {
}
public void mouseUp(MouseEvent e) {
setAllChecklist(checklist_tm, true);
}
public void mouseDoubleClick(MouseEvent e) {
}
});
Button tradNone = new Button(quickSelect, SWT.PUSH);
tradNone.setText("No Traditional");
tradNone.addMouseListener(new MouseListener() {
public void mouseDown(MouseEvent e) {
}
public void mouseUp(MouseEvent e) {
setAllChecklist(checklist_tm, false);
}
public void mouseDoubleClick(MouseEvent e) {
}
});
Button classAll = new Button(quickSelect, SWT.PUSH);
classAll.setText("All Class-level");
classAll.addMouseListener(new MouseListener() {
public void mouseDown(MouseEvent e) {
}
public void mouseUp(MouseEvent e) {
setAllChecklist(checklist_cm, true);
}
public void mouseDoubleClick(MouseEvent e) {
}
});
Button classNone = new Button(quickSelect, SWT.PUSH);
classNone.setText("No Class-level");
classNone.addMouseListener(new MouseListener() {
public void mouseDown(MouseEvent e) {
}
public void mouseUp(MouseEvent e) {
setAllChecklist(checklist_cm, false);
}
public void mouseDoubleClick(MouseEvent e) {
}
});
}
private void setAllChecklist(Button[] checklist, boolean value)
{
for (int i=0; i<checklist.length; i++)
checklist[i].setSelection(value);
validatePage();
}
static private void insertEmpty(Composite comp) {
Label label = new Label(comp, SWT.NONE);
setLayoutSpan(label, 3);
}
static private void setLayoutSpan(Control control, int span) {
GridData gd = new GridData();
gd.horizontalSpan = span;
control.setLayoutData(gd);
}
private static void setButtonGridData(Button button) {
GridData gridData= new GridData();
button.setLayoutData(gridData);
// SWTUtil.setButtonDimensionHint(button);
}
private static void setLayoutIndent(Control control, int indent) {
GridData gd = new GridData();
gd.horizontalIndent = indent;
control.setLayoutData(gd);
}
private static void setTop(Control control) {
GridData gd = new GridData();
control.setLayoutData(gd);
}
static private boolean isEmptyString(String string) {
return string == null || string.equals("");
}
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
String traditional = "";
String[] tr_str = MuClipseConstants.tm_operators;
for (int i=0;i<tr_str.length;i++)
traditional += "1";
configuration.setAttribute(
MuClipseConstants.TRAD_OPS,
traditional);
String classlevel = "";
String[] cl_str = MuClipseConstants.cm_operators;
for (int i=0;i<cl_str.length;i++)
classlevel += "1";
configuration.setAttribute(
MuClipseConstants.CLASS_OPS,
classlevel);
}
public void initializeFrom(ILaunchConfiguration configuration) {
try
{
boolean[] traditional =
MuClipsePlugin.BitStringToBools(
configuration.getAttribute(
MuClipseConstants.TRAD_OPS,
""));
if (traditional.length != checklist_tm.length)
{
for (int i=0;i<checklist_tm.length;i++)
checklist_tm[i].setSelection(false);
}
else
{
for (int i=0;i<checklist_tm.length;i++)
checklist_tm[i]
.setSelection(traditional[i]);
}
boolean[] classlevel =
MuClipsePlugin.BitStringToBools(
configuration.getAttribute(
MuClipseConstants.CLASS_OPS,
""));
if (classlevel.length != checklist_cm.length)
{
for (int i=0;i<checklist_cm.length;i++)
checklist_cm[i].setSelection(false);
}
else
{
for (int i=0;i<checklist_cm.length;i++)
checklist_cm[i]
.setSelection(classlevel[i]);
}
validatePage();
}
catch (CoreException e) {}
}
private void validatePage()
{
setMessage(null);
setErrorMessage(null);
setDirty(false);
boolean anyClassLevel = false;
for (int i=0;i<checklist_cm.length;i++)
{
if (checklist_cm[i].getSelection())
anyClassLevel = true;
}
boolean anyTraditional = false;
for (int i=0;i<checklist_tm.length;i++)
{
if (checklist_tm[i].getSelection())
anyTraditional = true;
}
if (!(anyClassLevel || anyTraditional))
{
setErrorMessage("Please select at least one mutation operator!");
setDirty(true);
}
updateLaunchConfigurationDialog();
}
public void performApply(
ILaunchConfigurationWorkingCopy configuration) {
boolean[] traditional =
new boolean[checklist_tm.length];
for (int i=0;i<checklist_tm.length; i++)
traditional[i] = checklist_tm[i].getSelection();
configuration.setAttribute(
MuClipseConstants.TRAD_OPS,
MuClipsePlugin.BoolsToBitString(traditional));
boolean[] classlevel =
new boolean[checklist_cm.length];
for (int i=0;i<checklist_cm.length; i++)
classlevel[i] = checklist_cm[i].getSelection();
configuration.setAttribute(
MuClipseConstants.CLASS_OPS,
MuClipsePlugin.BoolsToBitString(classlevel));
}
public String getName() {
return "Operators";
}
public boolean isValid(ILaunchConfiguration launchConfig) {
return getErrorMessage() == null;
}
}
}