1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-16 13:35:22 +02:00

merge from HEAD to fix 45668 & 45612

This commit is contained in:
David Inglis 2003-10-30 14:11:43 +00:00
parent 8303a99e46
commit 51281a34c5
2 changed files with 76 additions and 20 deletions

View file

@ -54,12 +54,15 @@ BuildPathInfoBlock.label=Paths and Symbols
BuildPathInfoBlock.paths=Include paths:
BuildPathInfoBlock.symbols=Defined symbols:
BuildPathInfoBlock.browse.path=New Include Path
BuildPathInfoBlock.browse.path.edit=Edit Include Path
BuildPathInfoBlock.browse.path.label=Path:
BuildPathInfoBlock.browse.symbol=New Defined Symbol
BuildPathInfoBlock.browse.symbol.edit=Edit Defined Symbol
BuildPathInfoBlock.browse.symbol.label=Symbol:
BuildPropertyCommon.label.title=Enter Value
BuildPropertyCommon.label.new=New...
BuildPropertyCommon.label.edit=Edit...
BuildPropertyCommon.label.remove=Remove
BuildPropertyCommon.label.up=Move Up
BuildPropertyCommon.label.down=Move Down

View file

@ -18,8 +18,8 @@ import org.eclipse.cdt.internal.ui.util.SWTUtil;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.MakeScannerInfo;
import org.eclipse.cdt.make.core.MakeScannerProvider;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.runtime.CoreException;
@ -33,15 +33,18 @@ import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.help.WorkbenchHelp;
public class BuildPathInfoBlock extends AbstractCOptionPage {
private static final int PROJECT_LIST_MULTIPLIER = 10;
private static final String PREF_SYMBOLS = "ScannerSymbols";
private static final String PREF_INCLUDES = "ScannerIncludes";
@ -51,10 +54,13 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
private static final String SYMBOLS = PREFIX + ".symbols"; //$NON-NLS-1$
private static final String BROWSE = PREFIX + ".browse"; //$NON-NLS-1$
private static final String PATH_TITLE = BROWSE + ".path"; //$NON-NLS-1$
private static final String EDIT_PATH_TITLE = BROWSE + ".path.edit"; //$NON-NLS-1$
private static final String PATH_LABEL = BROWSE + ".path.label"; //$NON-NLS-1$
private static final String SYMBOL_TITLE = BROWSE + ".symbol"; //$NON-NLS-1$
private static final String EDIT_SYMBOL_TITLE = BROWSE + ".symbol.edit"; //$NON-NLS-1$
private static final String SYMBOL_LABEL = BROWSE + ".symbol.label"; //$NON-NLS-1$
private static final String NEW = "BuildPropertyCommon.label.new"; //$NON-NLS-1$
private static final String EDIT = "BuildPropertyCommon.label.edit"; //$NON-NLS-1$
private static final String REMOVE = "BuildPropertyCommon.label.remove"; //$NON-NLS-1$
private static final String UP = "BuildPropertyCommon.label.up"; //$NON-NLS-1$
private static final String DOWN = "BuildPropertyCommon.label.down"; //$NON-NLS-1$
@ -63,18 +69,20 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
private List symbolList;
private Composite pathButtonComp;
private Button addPath;
private Button editPath;
private Button removePath;
private Button pathUp;
private Button pathDown;
private Composite symbolButtonComp;
private Button addSymbol;
private Button editSymbol;
private Button removeSymbol;
private Button symbolUp;
private Button symbolDown;
private Shell shell;
public BuildPathInfoBlock() {
super(CUIPlugin.getResourceString(LABEL));
super(MakeUIPlugin.getResourceString(LABEL));
setDescription("Set the include paths and preprocessor symbols for this project");
}
@ -84,7 +92,7 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
pathButtonComp.setFont(parent.getFont());
// Add the buttons
addPath = ControlFactory.createPushButton(pathButtonComp, CUIPlugin.getResourceString(NEW));
addPath = ControlFactory.createPushButton(pathButtonComp, MakeUIPlugin.getResourceString(NEW));
addPath.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
handleAddPath();
@ -95,7 +103,18 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
addPath.setLayoutData(new GridData());
SWTUtil.setButtonDimensionHint(addPath);
removePath = ControlFactory.createPushButton(pathButtonComp, CUIPlugin.getResourceString(REMOVE));
editPath = ControlFactory.createPushButton(pathButtonComp, MakeUIPlugin.getResourceString(EDIT));
editPath.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
editPathListItem();
}
});
editPath.setEnabled(true);
editPath.setFont(parent.getFont());
editPath.setLayoutData(new GridData());
SWTUtil.setButtonDimensionHint(editPath);
removePath = ControlFactory.createPushButton(pathButtonComp, MakeUIPlugin.getResourceString(REMOVE));
removePath.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
handleRemovePath();
@ -105,7 +124,7 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
removePath.setLayoutData(new GridData());
SWTUtil.setButtonDimensionHint(removePath);
pathUp = ControlFactory.createPushButton(pathButtonComp, CUIPlugin.getResourceString(UP));
pathUp = ControlFactory.createPushButton(pathButtonComp, MakeUIPlugin.getResourceString(UP));
pathUp.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
handlePathUp();
@ -115,7 +134,7 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
pathUp.setLayoutData(new GridData());
SWTUtil.setButtonDimensionHint(pathUp);
pathDown = ControlFactory.createPushButton(pathButtonComp, CUIPlugin.getResourceString(DOWN));
pathDown = ControlFactory.createPushButton(pathButtonComp, MakeUIPlugin.getResourceString(DOWN));
pathDown.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
handlePathDown();
@ -143,9 +162,28 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
// Make it occupy the first 2 columns
GridData gd = new GridData(GridData.FILL_BOTH);
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = numColumns - 1;
gd.heightHint = getDefaultFontHeight(pathList, PROJECT_LIST_MULTIPLIER);
pathList.setLayoutData(gd);
pathList.setFont(parent.getFont());
}
/**
* Get the defualt widget height for the supplied control.
* @return int
* @param control - the control being queried about fonts
* @param lines - the number of lines to be shown on the table.
*/
private static int getDefaultFontHeight(Control control, int lines) {
FontData[] viewerFontData = control.getFont().getFontData();
int fontHeight = 10;
//If we have no font data use our guess
if (viewerFontData.length > 0)
fontHeight = viewerFontData[0].getHeight();
return lines * fontHeight;
}
private void createSymbolListButtons(Composite parent) {
@ -154,7 +192,7 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
symbolButtonComp.setFont(parent.getFont());
// Add the buttons
addSymbol = ControlFactory.createPushButton(symbolButtonComp, CUIPlugin.getResourceString(NEW));
addSymbol = ControlFactory.createPushButton(symbolButtonComp, MakeUIPlugin.getResourceString(NEW));
addSymbol.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
handleAddSymbol();
@ -165,7 +203,18 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
addSymbol.setLayoutData(new GridData());
SWTUtil.setButtonDimensionHint(addSymbol);
removeSymbol = ControlFactory.createPushButton(symbolButtonComp, CUIPlugin.getResourceString(REMOVE));
editSymbol = ControlFactory.createPushButton(symbolButtonComp, MakeUIPlugin.getResourceString(EDIT));
editSymbol.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
editSymbolListItem();
}
});
editSymbol.setEnabled(true);
editSymbol.setFont(parent.getFont());
editSymbol.setLayoutData(new GridData());
SWTUtil.setButtonDimensionHint(editSymbol);
removeSymbol = ControlFactory.createPushButton(symbolButtonComp, MakeUIPlugin.getResourceString(REMOVE));
removeSymbol.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
handleRemoveSymbol();
@ -175,7 +224,7 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
removeSymbol.setLayoutData(new GridData());
SWTUtil.setButtonDimensionHint(removeSymbol);
symbolUp = ControlFactory.createPushButton(symbolButtonComp, CUIPlugin.getResourceString(UP));
symbolUp = ControlFactory.createPushButton(symbolButtonComp, MakeUIPlugin.getResourceString(UP));
symbolUp.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
handleSymbolUp();
@ -185,7 +234,7 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
symbolUp.setLayoutData(new GridData());
SWTUtil.setButtonDimensionHint(symbolUp);
symbolDown = ControlFactory.createPushButton(symbolButtonComp, CUIPlugin.getResourceString(DOWN));
symbolDown = ControlFactory.createPushButton(symbolButtonComp, MakeUIPlugin.getResourceString(DOWN));
symbolDown.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
handleSymbolDown();
@ -213,6 +262,8 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
// Make it occupy the first n-1 columns
GridData gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = numColumns - 1;
gd.grabExcessHorizontalSpace = true;
gd.heightHint = getDefaultFontHeight(pathList, PROJECT_LIST_MULTIPLIER);
symbolList.setLayoutData(gd);
symbolList.setFont(parent.getFont());
@ -301,8 +352,8 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
InputDialog dialog =
new InputDialog(
shell,
CUIPlugin.getResourceString(PATH_TITLE),
CUIPlugin.getResourceString(PATH_LABEL),
MakeUIPlugin.getResourceString(EDIT_PATH_TITLE),
MakeUIPlugin.getResourceString(PATH_LABEL),
selItem,
null);
String newItem = null;
@ -328,8 +379,8 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
InputDialog dialog =
new InputDialog(
shell,
CUIPlugin.getResourceString(SYMBOL_TITLE),
CUIPlugin.getResourceString(SYMBOL_LABEL),
MakeUIPlugin.getResourceString(EDIT_SYMBOL_TITLE),
MakeUIPlugin.getResourceString(SYMBOL_LABEL),
selItem,
null);
String newItem = null;
@ -350,12 +401,14 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
// Enable the remove button if there is at least 1 item in the list
int items = pathList.getItemCount();
if (items > 0) {
editPath.setEnabled(true);
removePath.setEnabled(true);
// Enable the up/down buttons depending on what item is selected
int index = pathList.getSelectionIndex();
pathUp.setEnabled(items > 1 && index > 0);
pathDown.setEnabled(items > 1 && index < (items - 1));
} else {
editPath.setEnabled(false);
removePath.setEnabled(false);
pathUp.setEnabled(false);
pathDown.setEnabled(false);
@ -366,12 +419,14 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
// Enable the remove button if there is at least 1 item in the list
int items = symbolList.getItemCount();
if (items > 0) {
editSymbol.setEnabled(true);
removeSymbol.setEnabled(true);
// Enable the up/down buttons depending on what item is selected
int index = symbolList.getSelectionIndex();
symbolUp.setEnabled(items > 1 && index > 0);
symbolDown.setEnabled(items > 1 && index < (items - 1));
} else {
editSymbol.setEnabled(false);
removeSymbol.setEnabled(false);
symbolUp.setEnabled(false);
symbolDown.setEnabled(false);
@ -393,7 +448,7 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
WorkbenchHelp.setHelp(getControl(), IMakeHelpContextIds.MAKE_PATH_SYMBOL_SETTINGS);
// Create a label for the include paths control
Label paths = ControlFactory.createLabel(composite, CUIPlugin.getResourceString(PATHS));
Label paths = ControlFactory.createLabel(composite, MakeUIPlugin.getResourceString(PATHS));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = tabColumns;
paths.setLayoutData(gd);
@ -405,7 +460,7 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
enablePathButtons();
// Create a label for the symbols control
Label symbols = ControlFactory.createLabel(composite, CUIPlugin.getResourceString(SYMBOLS));
Label symbols = ControlFactory.createLabel(composite, MakeUIPlugin.getResourceString(SYMBOLS));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = tabColumns;
symbols.setLayoutData(gd);
@ -433,8 +488,7 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
protected void handleAddPath() {
// Popup an entry dialog
InputDialog dialog =
new InputDialog(shell, CUIPlugin.getResourceString(PATH_TITLE), CUIPlugin.getResourceString(PATH_LABEL), "", null); //$NON-NLS-1$
InputDialog dialog = new InputDialog(shell, MakeUIPlugin.getResourceString(PATH_TITLE), MakeUIPlugin.getResourceString(PATH_LABEL), "", null); //$NON-NLS-1$
String path = null;
if (dialog.open() == InputDialog.OK) {
path = dialog.getValue();
@ -448,8 +502,7 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
protected void handleAddSymbol() {
// Popup an entry dialog
InputDialog dialog =
new InputDialog(shell, CUIPlugin.getResourceString(SYMBOL_TITLE), CUIPlugin.getResourceString(SYMBOL_LABEL), "", null); //$NON-NLS-1$
InputDialog dialog = new InputDialog(shell, MakeUIPlugin.getResourceString(SYMBOL_TITLE), MakeUIPlugin.getResourceString(SYMBOL_LABEL), "", null); //$NON-NLS-1$
String symbol = null;
if (dialog.open() == InputDialog.OK) {
symbol = dialog.getValue();