});
Button browseDescriptor = new Button(descriptorGroup, SWT.NONE);
browseDescriptor.setText("Browse ...");
browseDescriptor.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setTitle("Select descriptor");
dialog.setMessage("Select descriptor");
dialog.setInput(getWorkspaceRoot());
dialog.setInitialSelection(getWorkspaceRoot().findMember(descriptorText.getText()));
if (dialog.open() == IDialogConstants.OK_ID) {
IResource resource = (IResource) dialog.getFirstResult();
if (resource != null) {
String fileLoc = resource.getFullPath().toString();
descriptorText.setText(fileLoc);
}
}
}
});
// Input Resource Group
Group inputResourceGroup = new Group(projectComposite, SWT.None);
inputResourceGroup.setText("Input Resource:");
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
grab(true, false).applyTo(inputResourceGroup);
GridLayout inputResourceGroupLayout = new GridLayout(2, false);
inputResourceGroup.setLayout(inputResourceGroupLayout);
inputText = new Text(inputResourceGroup, SWT.BORDER);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
grab(true, false).applyTo(inputText);
inputText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
updateLaunchConfigurationDialog();
}
});
Button browseInputResource = new Button(inputResourceGroup, SWT.NONE);
browseInputResource.setText("Browse ...");
browseInputResource.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setTitle("Select input folder or file");
dialog.setMessage("Select input folder or file");
dialog.setInput(getSelectedProject());
dialog.setInitialSelection(getWorkspaceRoot().findMember(inputText.getText()));
if (dialog.open() == IDialogConstants.OK_ID) {
IResource resource = (IResource) dialog.getFirstResult();
if (resource != null) {
String fileLoc = resource.getFullPath().toString();
inputText.setText(fileLoc);
}
}
}
});
recursivelyButton = new Button(inputResourceGroup, SWT.CHECK);
recursivelyButton.setText("Recursively, read all files under each directory");
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
grab(true, false).applyTo(recursivelyButton);
recursivelyButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent event) {
updateLaunchConfigurationDialog();
}
public void widgetDefaultSelected(SelectionEvent event) {
}
});
Group inputFormatGroup = new Group(projectComposite, SWT.None);
inputFormatGroup.setText("Input Format:");
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
grab(true, false).applyTo(inputFormatGroup);
GridLayout inputFormatGroupLayout = new GridLayout(4, false);
inputFormatGroup.setLayout(inputFormatGroupLayout);
casButton = new Button(inputFormatGroup, SWT.RADIO);
casButton.setText("CASes (XMI or XCAS format)");
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
grab(true, false).span(4, 1).applyTo(casButton);
casButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent event) {
updateLaunchConfigurationDialog();
}
public void widgetDefaultSelected(SelectionEvent event) {
}
});
plainTextButton = new Button(inputFormatGroup, SWT.RADIO);
GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).
grab(false, false).applyTo(plainTextButton);
plainTextButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent event) {
encodingCombo.setEnabled(plainTextButton.getSelection());
languageText.setEnabled(plainTextButton.getSelection());
updateLaunchConfigurationDialog();
}
public void widgetDefaultSelected(SelectionEvent event) {
}
});
plainTextButton.setText("Plain Text, encoding:");
encodingCombo = new Combo(inputFormatGroup, SWT.NONE);
GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).
grab(false, false).applyTo(encodingCombo);
encodingCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
updateLaunchConfigurationDialog();
}
});
String defaultEncoding = Charset.defaultCharset().displayName();
Set<String> charsets = new HashSet<String>();
charsets.add("US-ASCII");
charsets.add("ISO-8859-1");
charsets.add("UTF-8");
charsets.add("UTF-16BE");
charsets.add("UTF-16LE");
charsets.add("UTF-16");
charsets.add(defaultEncoding);
encodingCombo.setItems(charsets.toArray(new String[charsets.size()]));
// Will be enabled by initializeForm if format is plain text
encodingCombo.setEnabled(false);
// Add language label
Label languageLabel = new Label(inputFormatGroup, SWT.NONE);
languageLabel.setText("Language:");
// Add language text field
languageText = new Text(inputFormatGroup, SWT.BORDER);
GridDataFactory.swtDefaults().hint(250, SWT.DEFAULT).align(SWT.LEFT, SWT.CENTER).
grab(true, false).applyTo(languageText);
languageText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
updateLaunchConfigurationDialog();
}
});
// Output Folder
Group outputFolderGroup = new Group(projectComposite, SWT.None);
outputFolderGroup.setText("Output Folder:");
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
grab(true, false).applyTo(outputFolderGroup);
GridLayout outputFolderGroupLayout = new GridLayout(2, false);
outputFolderGroup.setLayout(outputFolderGroupLayout);
outputFolderText = new Text(outputFolderGroup, SWT.BORDER);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
grab(true, false).applyTo(outputFolderText);
outputFolderText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
updateLaunchConfigurationDialog();
}
});
Button browseOutputFolderButton = new Button(outputFolderGroup, SWT.NONE);
browseOutputFolderButton.setText("Browse ...");
browseOutputFolderButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
// TODO: Only select elements within project
String currentContainerString = outputFolderText.getText();
IContainer currentContainer = getContainer(currentContainerString);
ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(),
currentContainer, false, "Select output folder");
dialog.showClosedProjects(false);
dialog.open();
Object[] results = dialog.getResult();
if ((results != null) && (results.length > 0) && (results[0] instanceof IPath)) {
IPath path = (IPath) results[0];
String containerName = path.toOSString();
outputFolderText.setText(containerName);
}