mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Added Variables... button to Discovered options page.
Resolved some concurrency issues.
This commit is contained in:
parent
ea15dddbc9
commit
6447835c74
4 changed files with 108 additions and 46 deletions
|
@ -271,6 +271,7 @@ ScannerConfigOptionsDialog.siProvider.browse.button=Browse...
|
||||||
ScannerConfigOptionsDialog.siProvider.browse.runCommandDialog='gcc' command:
|
ScannerConfigOptionsDialog.siProvider.browse.runCommandDialog='gcc' command:
|
||||||
ScannerConfigOptionsDialog.siProvider.command.errorMessage=Must enter compiler invocation command
|
ScannerConfigOptionsDialog.siProvider.command.errorMessage=Must enter compiler invocation command
|
||||||
ScannerConfigOptionsDialog.apply.progressMessage=Setting scanner configuration discovery options...
|
ScannerConfigOptionsDialog.apply.progressMessage=Setting scanner configuration discovery options...
|
||||||
|
ScannerConfigOptionsDialog.common.variables.button=Variables...
|
||||||
|
|
||||||
ScannerConfigOptionsDialog.unsavedchanges.title=Setting C/C++ Make Project Discovery Options
|
ScannerConfigOptionsDialog.unsavedchanges.title=Setting C/C++ Make Project Discovery Options
|
||||||
ScannerConfigOptionsDialog.unsavedchanges.message=The C/C++ Make Project Discovery Options property page contains unsaved modifications. Do you want to save changes so that other discovery related settings can be updated?
|
ScannerConfigOptionsDialog.unsavedchanges.message=The C/C++ Make Project Discovery Options property page contains unsaved modifications. Do you want to save changes so that other discovery related settings can be updated?
|
||||||
|
|
|
@ -10,9 +10,19 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.make.ui.dialogs;
|
package org.eclipse.cdt.make.ui.dialogs;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
|
||||||
|
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
||||||
|
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||||
|
import org.eclipse.debug.ui.StringVariableSelectionDialog;
|
||||||
import org.eclipse.jface.dialogs.DialogPage;
|
import org.eclipse.jface.dialogs.DialogPage;
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.widgets.Button;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract SCD profile page
|
* Abstract SCD profile page
|
||||||
|
@ -22,6 +32,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
public abstract class AbstractDiscoveryPage extends DialogPage {
|
public abstract class AbstractDiscoveryPage extends DialogPage {
|
||||||
protected static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
|
protected static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
|
||||||
protected static final String PROFILE_GROUP_LABEL = PREFIX + ".profile.group.label"; //$NON-NLS-1$
|
protected static final String PROFILE_GROUP_LABEL = PREFIX + ".profile.group.label"; //$NON-NLS-1$
|
||||||
|
private static final String VARIABLES_BUTTON = PREFIX + ".common.variables.button"; //$NON-NLS-1$
|
||||||
|
|
||||||
protected AbstractDiscoveryOptionsBlock fContainer; // parent
|
protected AbstractDiscoveryOptionsBlock fContainer; // parent
|
||||||
|
|
||||||
|
@ -59,6 +70,46 @@ public abstract class AbstractDiscoveryPage extends DialogPage {
|
||||||
super(title, image);
|
super(title, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Button addVariablesButton(Composite parent, final Text control) {
|
||||||
|
Button variablesButton = ControlFactory.createPushButton(parent,
|
||||||
|
MakeUIPlugin.getResourceString(VARIABLES_BUTTON));
|
||||||
|
((GridData) variablesButton.getLayoutData()).widthHint =
|
||||||
|
SWTUtil.getButtonWidthHint(variablesButton);
|
||||||
|
|
||||||
|
variablesButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||||
|
*/
|
||||||
|
public void widgetSelected(SelectionEvent arg0) {
|
||||||
|
handleVariablesButtonSelected(control);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return variablesButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A variable entry button has been pressed for the given text field. Prompt
|
||||||
|
* the user for a variable and enter the result in the given field.
|
||||||
|
*/
|
||||||
|
private void handleVariablesButtonSelected(Text textField) {
|
||||||
|
String variable = getVariable();
|
||||||
|
if (variable != null) {
|
||||||
|
textField.append(variable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prompts the user to choose and configure a variable and returns the
|
||||||
|
* resulting string, suitable to be used as an attribute.
|
||||||
|
*/
|
||||||
|
private String getVariable() {
|
||||||
|
StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
|
||||||
|
dialog.open();
|
||||||
|
return dialog.getVariableExpression();
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract boolean isValid();
|
protected abstract boolean isValid();
|
||||||
protected abstract void populateBuildInfo(IScannerConfigBuilderInfo2 buildInfo);
|
protected abstract void populateBuildInfo(IScannerConfigBuilderInfo2 buildInfo);
|
||||||
protected abstract void restoreFromBuildinfo(IScannerConfigBuilderInfo2 buildInfo);
|
protected abstract void restoreFromBuildinfo(IScannerConfigBuilderInfo2 buildInfo);
|
||||||
|
|
|
@ -44,8 +44,6 @@ import org.eclipse.swt.widgets.Text;
|
||||||
* @author vhirsl
|
* @author vhirsl
|
||||||
*/
|
*/
|
||||||
public class GCCPerFileSCDProfilePage extends AbstractDiscoveryPage {
|
public class GCCPerFileSCDProfilePage extends AbstractDiscoveryPage {
|
||||||
private static final int DEFAULT_HEIGHT = 60;
|
|
||||||
|
|
||||||
private static final String BO_PROVIDER_PARSER_ENABLED_BUTTON = PREFIX + ".boProvider.parser.enabled.button"; //$NON-NLS-1$
|
private static final String BO_PROVIDER_PARSER_ENABLED_BUTTON = PREFIX + ".boProvider.parser.enabled.button"; //$NON-NLS-1$
|
||||||
private static final String BO_PROVIDER_OPEN_LABEL = PREFIX + ".boProvider.open.label"; //$NON-NLS-1$
|
private static final String BO_PROVIDER_OPEN_LABEL = PREFIX + ".boProvider.open.label"; //$NON-NLS-1$
|
||||||
private static final String BO_PROVIDER_BROWSE_BUTTON = PREFIX + ".boProvider.browse.button"; //$NON-NLS-1$
|
private static final String BO_PROVIDER_BROWSE_BUTTON = PREFIX + ".boProvider.browse.button"; //$NON-NLS-1$
|
||||||
|
@ -99,7 +97,23 @@ public class GCCPerFileSCDProfilePage extends AbstractDiscoveryPage {
|
||||||
// load label
|
// load label
|
||||||
Label loadLabel = ControlFactory.createLabel(profileGroup,
|
Label loadLabel = ControlFactory.createLabel(profileGroup,
|
||||||
MakeUIPlugin.getResourceString(BO_PROVIDER_OPEN_LABEL));
|
MakeUIPlugin.getResourceString(BO_PROVIDER_OPEN_LABEL));
|
||||||
((GridData) loadLabel.getLayoutData()).horizontalSpan = 3;
|
((GridData) loadLabel.getLayoutData()).horizontalSpan = 2;
|
||||||
|
|
||||||
|
// load button
|
||||||
|
bopLoadButton = ControlFactory.createPushButton(profileGroup,
|
||||||
|
MakeUIPlugin.getResourceString(BO_PROVIDER_LOAD_BUTTON));
|
||||||
|
((GridData) bopLoadButton.getLayoutData()).widthHint =
|
||||||
|
SWTUtil.getButtonWidthHint(bopLoadButton);
|
||||||
|
bopLoadButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
|
public void widgetSelected(SelectionEvent event) {
|
||||||
|
handleBOPLoadFileButtonSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
if (getContainer().getProject() == null) { // project properties
|
||||||
|
bopLoadButton.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
// text field
|
// text field
|
||||||
bopOpenFileText = ControlFactory.createTextField(profileGroup, SWT.SINGLE | SWT.BORDER);
|
bopOpenFileText = ControlFactory.createTextField(profileGroup, SWT.SINGLE | SWT.BORDER);
|
||||||
|
@ -108,6 +122,7 @@ public class GCCPerFileSCDProfilePage extends AbstractDiscoveryPage {
|
||||||
handleModifyOpenFileText();
|
handleModifyOpenFileText();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
bopLoadButton.setEnabled(loadButtonInitialEnabled && handleModifyOpenFileText());
|
||||||
|
|
||||||
// browse button
|
// browse button
|
||||||
Button browseButton = ControlFactory.createPushButton(profileGroup,
|
Button browseButton = ControlFactory.createPushButton(profileGroup,
|
||||||
|
@ -141,22 +156,8 @@ public class GCCPerFileSCDProfilePage extends AbstractDiscoveryPage {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// load button
|
// variable button
|
||||||
bopLoadButton = ControlFactory.createPushButton(profileGroup,
|
addVariablesButton(profileGroup, bopOpenFileText);
|
||||||
MakeUIPlugin.getResourceString(BO_PROVIDER_LOAD_BUTTON));
|
|
||||||
((GridData) bopLoadButton.getLayoutData()).widthHint =
|
|
||||||
SWTUtil.getButtonWidthHint(bopLoadButton);
|
|
||||||
bopLoadButton.addSelectionListener(new SelectionAdapter() {
|
|
||||||
|
|
||||||
public void widgetSelected(SelectionEvent event) {
|
|
||||||
handleBOPLoadFileButtonSelected();
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
bopLoadButton.setEnabled(loadButtonInitialEnabled);
|
|
||||||
if (getContainer().getProject() == null) { // project properties
|
|
||||||
bopLoadButton.setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
setControl(page);
|
setControl(page);
|
||||||
// set the shell variable; must be after setControl
|
// set the shell variable; must be after setControl
|
||||||
|
@ -169,11 +170,12 @@ public class GCCPerFileSCDProfilePage extends AbstractDiscoveryPage {
|
||||||
initializeValues();
|
initializeValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleModifyOpenFileText() {
|
protected boolean handleModifyOpenFileText() {
|
||||||
String fileName = getBopOpenFileText();
|
String fileName = getBopOpenFileText();
|
||||||
bopLoadButton.setEnabled(bopEnabledButton.getSelection() &&
|
bopLoadButton.setEnabled(bopEnabledButton.getSelection() &&
|
||||||
fileName.length() > 0 &&
|
fileName.length() > 0 &&
|
||||||
(new File(fileName)).exists());
|
(new File(fileName)).exists());
|
||||||
|
return bopLoadButton.getEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getBopOpenFileText() {
|
private String getBopOpenFileText() {
|
||||||
|
@ -235,15 +237,18 @@ public class GCCPerFileSCDProfilePage extends AbstractDiscoveryPage {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!instance.shell.isDisposed()) {
|
if (!instance.shell.isDisposed()) {
|
||||||
instance.bopLoadButton.setEnabled(instance.bopEnabledButton.getSelection());
|
loadButtonInitialEnabled = instance.bopEnabledButton.getSelection() && handleModifyOpenFileText();
|
||||||
|
instance.bopLoadButton.setEnabled(loadButtonInitialEnabled);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
loadButtonInitialEnabled = true;
|
||||||
}
|
}
|
||||||
loadButtonInitialEnabled = instance.bopEnabledButton.getSelection();//true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
loadButtonInitialEnabled = instance.bopEnabledButton.getSelection();//true;
|
loadButtonInitialEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//lock.release();
|
//lock.release();
|
||||||
|
|
|
@ -44,8 +44,6 @@ import org.eclipse.swt.widgets.Text;
|
||||||
* @author vhirsl
|
* @author vhirsl
|
||||||
*/
|
*/
|
||||||
public class GCCPerProjectSCDProfilePage extends AbstractDiscoveryPage {
|
public class GCCPerProjectSCDProfilePage extends AbstractDiscoveryPage {
|
||||||
private static final int DEFAULT_HEIGHT = 160;
|
|
||||||
|
|
||||||
private static final String BO_PROVIDER_PARSER_ENABLED_BUTTON = PREFIX + ".boProvider.parser.enabled.button"; //$NON-NLS-1$
|
private static final String BO_PROVIDER_PARSER_ENABLED_BUTTON = PREFIX + ".boProvider.parser.enabled.button"; //$NON-NLS-1$
|
||||||
private static final String BO_PROVIDER_OPEN_LABEL = PREFIX + ".boProvider.open.label"; //$NON-NLS-1$
|
private static final String BO_PROVIDER_OPEN_LABEL = PREFIX + ".boProvider.open.label"; //$NON-NLS-1$
|
||||||
private static final String BO_PROVIDER_BROWSE_BUTTON = PREFIX + ".boProvider.browse.button"; //$NON-NLS-1$
|
private static final String BO_PROVIDER_BROWSE_BUTTON = PREFIX + ".boProvider.browse.button"; //$NON-NLS-1$
|
||||||
|
@ -111,7 +109,23 @@ public class GCCPerProjectSCDProfilePage extends AbstractDiscoveryPage {
|
||||||
// load label
|
// load label
|
||||||
Label loadLabel = ControlFactory.createLabel(profileGroup,
|
Label loadLabel = ControlFactory.createLabel(profileGroup,
|
||||||
MakeUIPlugin.getResourceString(BO_PROVIDER_OPEN_LABEL));
|
MakeUIPlugin.getResourceString(BO_PROVIDER_OPEN_LABEL));
|
||||||
((GridData) loadLabel.getLayoutData()).horizontalSpan = 3;
|
((GridData) loadLabel.getLayoutData()).horizontalSpan = 2;
|
||||||
|
|
||||||
|
// load button
|
||||||
|
bopLoadButton = ControlFactory.createPushButton(profileGroup,
|
||||||
|
MakeUIPlugin.getResourceString(BO_PROVIDER_LOAD_BUTTON));
|
||||||
|
((GridData) bopLoadButton.getLayoutData()).widthHint =
|
||||||
|
SWTUtil.getButtonWidthHint(bopLoadButton);
|
||||||
|
bopLoadButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
|
public void widgetSelected(SelectionEvent event) {
|
||||||
|
handleBOPLoadFileButtonSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
if (getContainer().getProject() == null) { // project properties
|
||||||
|
bopLoadButton.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
// text field
|
// text field
|
||||||
bopOpenFileText = ControlFactory.createTextField(profileGroup, SWT.SINGLE | SWT.BORDER);
|
bopOpenFileText = ControlFactory.createTextField(profileGroup, SWT.SINGLE | SWT.BORDER);
|
||||||
|
@ -120,6 +134,7 @@ public class GCCPerProjectSCDProfilePage extends AbstractDiscoveryPage {
|
||||||
handleModifyOpenFileText();
|
handleModifyOpenFileText();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
bopLoadButton.setEnabled(loadButtonInitialEnabled && handleModifyOpenFileText());
|
||||||
|
|
||||||
// browse button
|
// browse button
|
||||||
Button browseButton = ControlFactory.createPushButton(profileGroup,
|
Button browseButton = ControlFactory.createPushButton(profileGroup,
|
||||||
|
@ -153,22 +168,8 @@ public class GCCPerProjectSCDProfilePage extends AbstractDiscoveryPage {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// load button
|
// variable button
|
||||||
bopLoadButton = ControlFactory.createPushButton(profileGroup,
|
addVariablesButton(profileGroup, bopOpenFileText);
|
||||||
MakeUIPlugin.getResourceString(BO_PROVIDER_LOAD_BUTTON));
|
|
||||||
((GridData) bopLoadButton.getLayoutData()).widthHint =
|
|
||||||
SWTUtil.getButtonWidthHint(bopLoadButton);
|
|
||||||
bopLoadButton.addSelectionListener(new SelectionAdapter() {
|
|
||||||
|
|
||||||
public void widgetSelected(SelectionEvent event) {
|
|
||||||
handleBOPLoadFileButtonSelected();
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
bopLoadButton.setEnabled(loadButtonInitialEnabled);
|
|
||||||
if (getContainer().getProject() == null) { // project properties
|
|
||||||
bopLoadButton.setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
ControlFactory.createSeparator(profileGroup, 3);
|
ControlFactory.createSeparator(profileGroup, 3);
|
||||||
|
|
||||||
|
@ -238,11 +239,12 @@ public class GCCPerProjectSCDProfilePage extends AbstractDiscoveryPage {
|
||||||
initializeValues();
|
initializeValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleModifyOpenFileText() {
|
protected boolean handleModifyOpenFileText() {
|
||||||
String fileName = getBopOpenFileText();
|
String fileName = getBopOpenFileText();
|
||||||
bopLoadButton.setEnabled(bopEnabledButton.getSelection() &&
|
bopLoadButton.setEnabled(bopEnabledButton.getSelection() &&
|
||||||
fileName.length() > 0 &&
|
fileName.length() > 0 &&
|
||||||
new File(fileName).exists());
|
new File(fileName).exists());
|
||||||
|
return bopLoadButton.getEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleModifyRunCommandText() {
|
protected void handleModifyRunCommandText() {
|
||||||
|
@ -313,15 +315,18 @@ public class GCCPerProjectSCDProfilePage extends AbstractDiscoveryPage {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!instance.shell.isDisposed()) {
|
if (!instance.shell.isDisposed()) {
|
||||||
instance.bopLoadButton.setEnabled(instance.bopEnabledButton.getSelection());
|
loadButtonInitialEnabled = instance.bopEnabledButton.getSelection() && handleModifyOpenFileText();
|
||||||
|
instance.bopLoadButton.setEnabled(loadButtonInitialEnabled);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
loadButtonInitialEnabled = true;
|
||||||
}
|
}
|
||||||
loadButtonInitialEnabled = instance.bopEnabledButton.getSelection();//true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
loadButtonInitialEnabled = instance.bopEnabledButton.getSelection();//true;
|
loadButtonInitialEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//lock.release();
|
//lock.release();
|
||||||
|
|
Loading…
Add table
Reference in a new issue