1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-16 20:55:44 +02:00

Bug 300917 - need a new version of XL C/C++ Compiler properties page for John Liu

This commit is contained in:
Vivian Kong 2010-01-27 19:45:01 +00:00
parent 6764511b39
commit 6621f5653e

View file

@ -29,35 +29,44 @@ import org.eclipse.ui.IWorkbenchPropertyPage;
public class XLCompilerPropertyPage extends FieldEditorPreferencePage implements IWorkbenchPropertyPage {
private String originalMessage;
protected String originalMessage;
/* (non-Javadoc)
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
*/
protected void createFieldEditors() {
createPathEditor();
createVersionEditor();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
* ()
*/
protected void createPathEditor() {
Composite parent = getFieldEditorParent();
fPathEditor = new DirectoryFieldEditor(PreferenceConstants.P_XL_COMPILER_ROOT, Messages.XLCompilerPropertyPage_0, parent)
{
protected boolean doCheckState()
{
// always return true, as we don't want to fail cases when compiler is installed remotely
fPathEditor = new DirectoryFieldEditor(PreferenceConstants.P_XL_COMPILER_ROOT,
Messages.XLCompilerPropertyPage_0, parent) {
protected boolean doCheckState() {
// always return true, as we don't want to fail cases when
// compiler is installed remotely
// just warn user
if (!super.doCheckState())
{
if (!super.doCheckState()) {
setMessage(Messages.XLCompilerPropertyPage_2, IMessageProvider.WARNING);
}
else
{
} else {
setMessage(originalMessage);
}
return true;
}
protected boolean checkState()
{
protected boolean checkState() {
return doCheckState();
}
@ -77,7 +86,7 @@ public class XLCompilerPropertyPage extends FieldEditorPreferencePage implements
e.printStackTrace();
}
if(currentPath == null) {
if (currentPath == null) {
// if the property isn't set, then use the workbench preference
IPreferenceStore prefStore = XLCUIPlugin.getDefault().getPreferenceStore();
currentPath = prefStore.getString(PreferenceConstants.P_XL_COMPILER_ROOT);
@ -85,9 +94,13 @@ public class XLCompilerPropertyPage extends FieldEditorPreferencePage implements
fPathEditor.setStringValue(currentPath);
String[] versionEntries = {PreferenceConstants.P_XL_COMPILER_VERSION_8_NAME,
PreferenceConstants.P_XL_COMPILER_VERSION_9_NAME,
PreferenceConstants.P_XL_COMPILER_VERSION_10_NAME};
}
protected void createVersionEditor() {
IProject project = ((IResource) (getElement().getAdapter(IResource.class))).getProject();
String[] versionEntries = { PreferenceConstants.P_XL_COMPILER_VERSION_8_NAME,
PreferenceConstants.P_XL_COMPILER_VERSION_9_NAME, PreferenceConstants.P_XL_COMPILER_VERSION_10_NAME };
Composite versionParent = getFieldEditorParent();
@ -105,7 +118,7 @@ public class XLCompilerPropertyPage extends FieldEditorPreferencePage implements
e.printStackTrace();
}
if(currentVersion == null) {
if (currentVersion == null) {
// if the property isn't set, then use the workbench preference
IPreferenceStore prefStore = XLCUIPlugin.getDefault().getPreferenceStore();
currentVersion = prefStore.getString(PreferenceConstants.P_XLC_COMPILER_VERSION);
@ -116,12 +129,11 @@ public class XLCompilerPropertyPage extends FieldEditorPreferencePage implements
}
private DirectoryFieldEditor fPathEditor;
protected DirectoryFieldEditor fPathEditor;
private BuildOptionComboFieldEditor fVersionEditor;
//private Composite parent;
protected BuildOptionComboFieldEditor fVersionEditor;
// private Composite parent;
/**
* Constructor for SamplePropertyPage.
@ -132,21 +144,23 @@ public class XLCompilerPropertyPage extends FieldEditorPreferencePage implements
originalMessage = getMessage();
}
protected void performDefaults() {
// default to whatever is set on the workbench preference
IPreferenceStore prefStore = XLCUIPlugin.getDefault().getPreferenceStore();
String currentPath = prefStore.getString(PreferenceConstants.P_XL_COMPILER_ROOT);
String currentVersion = prefStore.getString(PreferenceConstants.P_XLC_COMPILER_VERSION);
String currentVersionLabel = PreferenceConstants.getVersionLabel(currentVersion);
if (fPathEditor != null) {
fPathEditor.setStringValue(currentPath);
}
fVersionEditor.getComboControl(getFieldEditorParent()).setText(currentVersionLabel);
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk()
*/
public boolean performOk() {
@ -154,10 +168,10 @@ public class XLCompilerPropertyPage extends FieldEditorPreferencePage implements
try {
IProject project = ((IResource) (getElement().getAdapter(IResource.class))).getProject();
if (fPathEditor != null) {
project.setPersistentProperty(new QualifiedName("", //$NON-NLS-1$
PreferenceConstants.P_XL_COMPILER_ROOT), fPathEditor
.getStringValue());
PreferenceConstants.P_XL_COMPILER_ROOT), fPathEditor.getStringValue());
}
String version = null;
if (fVersionEditor.getSelection() != null) {
version = PreferenceConstants.getVersion(fVersionEditor.getSelection());
@ -178,6 +192,7 @@ public class XLCompilerPropertyPage extends FieldEditorPreferencePage implements
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
*/
public IAdaptable getElement() {