mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 04:45:38 +02:00
Bug #179169: partial fix
This commit is contained in:
parent
b6f422c417
commit
d9128568c0
2 changed files with 32 additions and 50 deletions
|
@ -243,7 +243,7 @@ public class CPropertyVarsTab extends AbstractCPropertyTab {
|
||||||
public void buttonPressed(int index){
|
public void buttonPressed(int index){
|
||||||
switch(index){
|
switch(index){
|
||||||
case 0:{
|
case 0:{
|
||||||
NewVarDialog dlg = new NewVarDialog(usercomp.getShell(), null, cfgd);
|
NewVarDialog dlg = new NewVarDialog(usercomp.getShell(), null, cfgd, mgr.getVariables(cfgd));
|
||||||
if(dlg.open() == Dialog.OK){
|
if(dlg.open() == Dialog.OK){
|
||||||
ICdtVariable macro = dlg.getDefinedMacro();
|
ICdtVariable macro = dlg.getDefinedMacro();
|
||||||
if(canCreate(macro)) {
|
if(canCreate(macro)) {
|
||||||
|
@ -265,7 +265,7 @@ public class CPropertyVarsTab extends AbstractCPropertyTab {
|
||||||
case 1:{
|
case 1:{
|
||||||
ICdtVariable _vars[] = getSelectedUserMacros();
|
ICdtVariable _vars[] = getSelectedUserMacros();
|
||||||
if(_vars != null && _vars.length == 1){
|
if(_vars != null && _vars.length == 1){
|
||||||
NewVarDialog dlg = new NewVarDialog(usercomp.getShell() ,_vars[0], cfgd);
|
NewVarDialog dlg = new NewVarDialog(usercomp.getShell() ,_vars[0], cfgd, mgr.getVariables(cfgd));
|
||||||
if(dlg.open() == Dialog.OK){
|
if(dlg.open() == Dialog.OK){
|
||||||
ICdtVariable macro = dlg.getDefinedMacro();
|
ICdtVariable macro = dlg.getDefinedMacro();
|
||||||
if(canCreate(macro)) {
|
if(canCreate(macro)) {
|
||||||
|
|
|
@ -93,10 +93,10 @@ public class NewVarDialog extends Dialog {
|
||||||
private Composite fListEditorContainier;
|
private Composite fListEditorContainier;
|
||||||
|
|
||||||
private FileListControl fListEditor;
|
private FileListControl fListEditor;
|
||||||
ICConfigurationDescription cfgd;
|
private ICConfigurationDescription cfgd;
|
||||||
|
private ICdtVariable[] vars;
|
||||||
|
|
||||||
public NewVarDialog(Shell parentShell, ICdtVariable editedMacro, ICConfigurationDescription _cfgd) {
|
public NewVarDialog(Shell parentShell, ICdtVariable editedMacro, ICConfigurationDescription _cfgd, ICdtVariable[] _vars) {
|
||||||
super(parentShell);
|
super(parentShell);
|
||||||
cfgd = _cfgd;
|
cfgd = _cfgd;
|
||||||
if(editedMacro != null)
|
if(editedMacro != null)
|
||||||
|
@ -104,6 +104,7 @@ public class NewVarDialog extends Dialog {
|
||||||
else
|
else
|
||||||
fTitle = UIMessages.getString(TITLE_NEW);
|
fTitle = UIMessages.getString(TITLE_NEW);
|
||||||
fEditedMacro = editedMacro;
|
fEditedMacro = editedMacro;
|
||||||
|
vars = _vars;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -239,10 +240,9 @@ public class NewVarDialog extends Dialog {
|
||||||
// fListEditor.setContext(fMacrosBlock.getContextInfo());
|
// fListEditor.setContext(fMacrosBlock.getContextInfo());
|
||||||
|
|
||||||
if(fEditedMacro != null){
|
if(fEditedMacro != null){
|
||||||
loadMacroSettings(fEditedMacro,true);
|
loadVar(fEditedMacro);
|
||||||
fMacroNameEdit.setEnabled(false);
|
fMacroNameEdit.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return comp;
|
return comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,18 +250,13 @@ public class NewVarDialog extends Dialog {
|
||||||
* get the names to be displayed in the var Name combo.
|
* get the names to be displayed in the var Name combo.
|
||||||
*/
|
*/
|
||||||
private String[] getMacroNames(){
|
private String[] getMacroNames(){
|
||||||
IBuildMacro macros[] = null;
|
|
||||||
//TODO:
|
|
||||||
//fMacrosBlock.getSystemMacros(true);
|
|
||||||
String names[] = null;
|
String names[] = null;
|
||||||
if(macros == null || macros.length == 0)
|
if(vars == null || vars.length == 0)
|
||||||
names = new String[0];
|
names = new String[0];
|
||||||
else{
|
else{
|
||||||
names = new String[macros.length];
|
names = new String[vars.length];
|
||||||
for(int i = 0; i < macros.length; i++){
|
for(int i = 0; i < vars.length; i++)
|
||||||
names[i] = macros[i].getName();
|
names[i] = vars[i].getName();
|
||||||
}
|
|
||||||
|
|
||||||
final Collator collator = Collator.getInstance();
|
final Collator collator = Collator.getInstance();
|
||||||
Arrays.sort(names, new Comparator() {
|
Arrays.sort(names, new Comparator() {
|
||||||
public int compare(final Object a, final Object b) {
|
public int compare(final Object a, final Object b) {
|
||||||
|
@ -271,7 +266,6 @@ public class NewVarDialog extends Dialog {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,55 +313,48 @@ public class NewVarDialog extends Dialog {
|
||||||
*/
|
*/
|
||||||
private void handleMacroNameSelection(){
|
private void handleMacroNameSelection(){
|
||||||
int index = fMacroNameEdit.getSelectionIndex();
|
int index = fMacroNameEdit.getSelectionIndex();
|
||||||
if(index == -1)
|
if (index != -1)
|
||||||
loadMacroSettings(null);
|
loadVarSettings(fMacroNameEdit.getItem(index));
|
||||||
else
|
|
||||||
loadMacroSettings(fMacroNameEdit.getItem(index));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadMacroSettings(String name){
|
private void loadVarSettings(String name) {
|
||||||
IBuildMacro macro = null;
|
ICdtVariable v = null;
|
||||||
// TODO:
|
for (int i=0; i<vars.length; i++) {
|
||||||
// fMacrosBlock.getSystemMacro(name,true);
|
if (vars[i].getName().equals(name)) {
|
||||||
if(macro != null)
|
v = vars[i];
|
||||||
loadMacroSettings(macro,false);
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(v != null)
|
||||||
|
loadVar(v);
|
||||||
else
|
else
|
||||||
loadMacroSettings(name,IBuildMacro.VALUE_TEXT,EMPTY_STRING);
|
loadVar(name,IBuildMacro.VALUE_TEXT,EMPTY_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadMacroSettings(String name,
|
private void loadVar(String name, int type, String value[]){
|
||||||
int type,
|
|
||||||
String value[]){
|
|
||||||
setSelectedType(type);
|
setSelectedType(type);
|
||||||
setSelectedMacroName(notNull(name));
|
setSelectedMacroName(notNull(name));
|
||||||
fListEditor.setList(value);
|
fListEditor.setList(value);
|
||||||
|
|
||||||
updateWidgetState();
|
updateWidgetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadMacroSettings(String name,
|
private void loadVar(String name, int type, String value){
|
||||||
int type,
|
|
||||||
String value){
|
|
||||||
|
|
||||||
setSelectedType(type);
|
setSelectedType(type);
|
||||||
setSelectedMacroName(notNull(name));
|
setSelectedMacroName(notNull(name));
|
||||||
fMacroValueEdit.setText(notNull(value));
|
fMacroValueEdit.setText(notNull(value));
|
||||||
|
|
||||||
updateWidgetState();
|
updateWidgetState();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* loads all the dialog fields with the variable settings
|
* loads all the dialog fields with the variable settings
|
||||||
*/
|
*/
|
||||||
private void loadMacroSettings(ICdtVariable var, boolean isUser){
|
private void loadVar(ICdtVariable var){
|
||||||
try{
|
try{
|
||||||
if(CdtVariableResolver.isStringListVariable(var.getValueType()))
|
if(CdtVariableResolver.isStringListVariable(var.getValueType()))
|
||||||
loadMacroSettings(var.getName(),var.getValueType(),var.getStringListValue());
|
loadVar(var.getName(),var.getValueType(),var.getStringListValue());
|
||||||
else
|
else
|
||||||
loadMacroSettings(var.getName(),var.getValueType(),var.getStringValue());
|
loadVar(var.getName(),var.getValueType(),var.getStringValue());
|
||||||
}catch(CdtVariableException e){
|
}catch(CdtVariableException e){}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -510,16 +497,11 @@ public class NewVarDialog extends Dialog {
|
||||||
private void handleMacroNameModified(){
|
private void handleMacroNameModified(){
|
||||||
String name = getSelectedVarName();
|
String name = getSelectedVarName();
|
||||||
if(fTypedName == null || !fTypedName.equals(name)){
|
if(fTypedName == null || !fTypedName.equals(name)){
|
||||||
loadMacroSettings(name);
|
loadVarSettings(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
private void handleMacroValueModified(){}
|
||||||
* called when the macro value is modified
|
|
||||||
*/
|
|
||||||
private void handleMacroValueModified(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* called when the operation is modified
|
* called when the operation is modified
|
||||||
|
|
Loading…
Add table
Reference in a new issue