From 45581a740cba53f9580af04054612c180723a9d3 Mon Sep 17 00:00:00 2001 From: Oleg Krasilnikov Date: Fri, 13 Apr 2007 11:29:35 +0000 Subject: [PATCH] Bug #182290 : add CDT vars/symbols to all languages --- .../cdt/ui/newui/AbstractLangsListTab.java | 16 ++++-- .../cdt/ui/newui/AbstractPropertyDialog.java | 1 + .../eclipse/cdt/ui/newui/IncludeDialog.java | 54 ++++++++++++------- .../org/eclipse/cdt/ui/newui/IncludeTab.java | 3 +- .../eclipse/cdt/ui/newui/LibraryPathTab.java | 2 + .../org/eclipse/cdt/ui/newui/LibraryTab.java | 2 + .../cdt/ui/newui/PluginResources.properties | 2 +- .../eclipse/cdt/ui/newui/SymbolDialog.java | 42 +++++++++------ .../org/eclipse/cdt/ui/newui/SymbolTab.java | 3 +- 9 files changed, 83 insertions(+), 42 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java index 084753287d6..9886fdfbd8a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java @@ -63,7 +63,8 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { protected Tree langTree; protected TreeColumn langCol; protected Button showBIButton; - protected boolean toAll = false; + protected boolean toAllCfgs = false; + protected boolean toAllLang = false; // protected boolean showBI = false; // boolean savedShowBI = false; @@ -332,10 +333,11 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { switch (i) { case 0: // add - toAll = false; + toAllCfgs = false; + toAllLang = false; ent = doAdd(); if (ent != null) { - if (toAll) { + if (toAllCfgs || toAllLang) { addToAll(ent); } else { incs.add(ent); @@ -399,13 +401,17 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { */ private void addToAll(ICLanguageSettingEntry ent) { ICConfigurationDescription[] cfgs = page.getCfgsEditable(); + ICResourceDescription cur_cfg = page.getResDesc(); String id = lang.getName(); // getLanguageId() sometimes returns null. for (int i = 0; i < cfgs.length; i++) { ICResourceDescription rcfg = page.getResDesc(cfgs[i]); - if (rcfg == null) continue; + if (rcfg == null) + continue; + if (!toAllCfgs && !(cur_cfg.equals(rcfg))) + continue; ICLanguageSetting [] ls = getLangSetting(rcfg); for (int j = 0; j < ls.length; j++ ) { - if (id == ls[j].getName()) { + if (id == ls[j].getName() || toAllLang) { List lst = ls[j].getSettingEntriesList(getKind()); lst.add(ent); ls[j].setSettingEntries(getKind(), lst); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPropertyDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPropertyDialog.java index b5ea97f1f7f..9123ed6e7ee 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPropertyDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPropertyDialog.java @@ -34,6 +34,7 @@ public abstract class AbstractPropertyDialog extends Dialog { public Object data = null; public boolean check1 = false; public boolean check2 = false; + public boolean check3 = false; public String text1; public String text2; private Shell parent; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java index 122c512f632..e0015b8b966 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java @@ -31,7 +31,8 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry; public class IncludeDialog extends AbstractPropertyDialog { public String sdata; - public Button b_add2all; + private Button b_add2confs; + private Button b_add2langs; public Text text; private Button b_work; private Button b_file; @@ -62,7 +63,7 @@ public class IncludeDialog extends AbstractPropertyDialog { } protected Control createDialogArea(Composite c) { - c.setLayout(new GridLayout(5, true)); + c.setLayout(new GridLayout(3, true)); GridData gd; Label l1 = new Label(c, SWT.NONE); @@ -71,40 +72,48 @@ public class IncludeDialog extends AbstractPropertyDialog { else l1.setText(UIMessages.getString("IncludeDialog.1")); //$NON-NLS-1$ gd = new GridData(GridData.BEGINNING); - gd.horizontalSpan = 5; + gd.horizontalSpan = 3; l1.setLayoutData(gd); text = new Text(c, SWT.SINGLE | SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 5; - gd.widthHint = 400; + gd.horizontalSpan = 3; + gd.widthHint = 450; text.setLayoutData(gd); if ((mode & OLD_MASK) == OLD_MASK) { text.setText(sdata); } text.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { setButtons(); }}); - b_add2all = new Button(c, SWT.CHECK); - b_add2all.setText(UIMessages.getString("IncludeDialog.2")); //$NON-NLS-1$ + + b_add2confs = new Button(c, SWT.CHECK); + b_add2confs.setText(UIMessages.getString("IncludeDialog.2")); //$NON-NLS-1$ gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 4; + gd.horizontalSpan = 2; if ((mode & OLD_MASK) == OLD_MASK) { gd.heightHint = 1; - b_add2all.setVisible(false); + b_add2confs.setVisible(false); } - b_add2all.setLayoutData(gd); - - b_vars = setupButton(c, AbstractCPropertyTab.VARIABLESBUTTON_NAME); - new Label(c, 0).setLayoutData(new GridData()); // placeholder - b_ok = setupButton(c, IDialogConstants.OK_LABEL); - b_ko = setupButton(c, IDialogConstants.CANCEL_LABEL); - b_work = setupButton(c, AbstractCPropertyTab.WORKSPACEBUTTON_NAME); - b_file = setupButton(c, AbstractCPropertyTab.FILESYSTEMBUTTON_NAME); + b_add2confs.setLayoutData(gd); + b_vars = setupButton(c, AbstractCPropertyTab.VARIABLESBUTTON_NAME); + + b_add2langs = new Button(c, SWT.CHECK); + b_add2langs.setText(UIMessages.getString("IncludeDialog.3")); //$NON-NLS-1$ + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = 2; + if ((mode & OLD_MASK) == OLD_MASK) { + gd.heightHint = 1; + b_add2langs.setVisible(false); + } + b_add2langs.setLayoutData(gd); + + b_work = setupButton(c, AbstractCPropertyTab.WORKSPACEBUTTON_NAME); + c_wsp = new Button(c, SWT.CHECK); c_wsp.setText(UIMessages.getString("ExpDialog.4")); //$NON-NLS-1$ gd = new GridData(GridData.BEGINNING); - gd.horizontalSpan = 5; + gd.horizontalSpan = 2; c_wsp.setLayoutData(gd); c_wsp.setSelection(isWsp); c_wsp.addSelectionListener(new SelectionAdapter() { @@ -113,6 +122,12 @@ public class IncludeDialog extends AbstractPropertyDialog { }}); c_wsp.setImage(AbstractExportTab.getWspImage(isWsp)); + + b_file = setupButton(c, AbstractCPropertyTab.FILESYSTEMBUTTON_NAME); + + new Label(c, 0).setLayoutData(new GridData()); // placeholder + b_ok = setupButton(c, IDialogConstants.OK_LABEL); + b_ko = setupButton(c, IDialogConstants.CANCEL_LABEL); c.getShell().setDefaultButton(b_ok); c.pack(); @@ -128,8 +143,9 @@ public class IncludeDialog extends AbstractPropertyDialog { String s; if (e.widget.equals(b_ok)) { text1 = text.getText(); - check1 = b_add2all.getSelection(); + check1 = b_add2confs.getSelection(); check2 = c_wsp.getSelection(); + check3 = b_add2langs.getSelection(); result = true; shell.dispose(); } else if (e.widget.equals(b_ko)) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java index b0fc4d272f0..3429d8c5fa1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java @@ -32,7 +32,8 @@ public class IncludeTab extends AbstractLangsListTab { UIMessages.getString("IncludeTab.1"), //$NON-NLS-1$ EMPTY_STR, getResDesc().getConfiguration(), 0); if (dlg.open() && dlg.text1.trim().length() > 0 ) { - toAll = dlg.check1; + toAllCfgs = dlg.check1; + toAllLang = dlg.check3; int flags = 0; if (dlg.check2) { // isWsp flags = ICSettingEntry.VALUE_WORKSPACE_PATH; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java index f56be997fff..ea182185ecd 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java @@ -48,6 +48,8 @@ public class LibraryPathTab extends AbstractLangsListTab implements IPathEntrySt UIMessages.getString("LibraryPathTab.1"), //$NON-NLS-1$ EMPTY_STR, getResDesc().getConfiguration(), 0); if (dlg.open() && dlg.text1.trim().length() > 0 ) { + toAllCfgs = dlg.check1; + toAllLang = dlg.check3; int flags = 0; if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH; return new CLibraryPathEntry(dlg.text1, flags); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java index c83e05b5c38..03fd0c12764 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java @@ -48,6 +48,8 @@ public class LibraryTab extends AbstractLangsListTab implements IPathEntryStoreL UIMessages.getString("LibraryTab.1"), //$NON-NLS-1$ EMPTY_STR, getResDesc().getConfiguration(), 0); if (dlg.open() && dlg.text1.trim().length() > 0 ) { + toAllCfgs = dlg.check1; + toAllLang = dlg.check3; int flags = 0; if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH; return new CLibraryFileEntry(dlg.text1, flags); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties index 758840196f8..d4c5b7adc12 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties @@ -446,6 +446,7 @@ IncludeTab.2=Change directory path IncludeDialog.0=Directory : IncludeDialog.1=File : IncludeDialog.2=Add to all configurations +IncludeDialog.3=Add to all languages LanguagesTab.0=Content type LanguagesTab.1=Language LibraryPathTab.0=Library paths @@ -475,7 +476,6 @@ ConfigMultiSelectionDialog.0=Select configurations ConfigMultiSelectionDialog.1=At least 2 configurations should be selected SymbolDialog.0=Name: SymbolDialog.1=Value: -SymbolDialog.2=Add to all configurations ConfigDescriptionTab.0=Project Description ConfigDescriptionTab.1=Configuration Description ConfigDescriptionTab.2=Resource Description diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java index 563635e9e1e..9f05cbe15df 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java @@ -28,16 +28,17 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.cdt.core.settings.model.ICResourceDescription; public class SymbolDialog extends AbstractPropertyDialog { - String data1; - String data2; - Button b_add2all; - Text txt1; - Text txt2; - Button b_vars; - Button b_ok; - Button b_ko; - boolean newAction; - ICResourceDescription cfgd; + private String data1; + private String data2; + private Button b_add2conf; + private Button b_add2lang; + private Text txt1; + private Text txt2; + private Button b_vars; + private Button b_ok; + private Button b_ko; + private boolean newAction; + private ICResourceDescription cfgd; public SymbolDialog(Shell parent, boolean _newAction, String title, String _data1, String _data2, @@ -83,13 +84,23 @@ public class SymbolDialog extends AbstractPropertyDialog { b_vars = setupButton(c, AbstractCPropertyTab.VARIABLESBUTTON_NAME); - b_add2all = new Button(c, SWT.CHECK); - b_add2all.setText(UIMessages.getString("SymbolDialog.2")); //$NON-NLS-1$ + b_add2conf = new Button(c, SWT.CHECK); + b_add2conf.setText(UIMessages.getString("IncludeDialog.2")); //$NON-NLS-1$ gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 4; - b_add2all.setLayoutData(gd); + b_add2conf.setLayoutData(gd); if (!newAction) { - b_add2all.setVisible(false); + b_add2conf.setVisible(false); + txt1.setEnabled(false); // don't change name + } + + b_add2lang = new Button(c, SWT.CHECK); + b_add2lang.setText(UIMessages.getString("IncludeDialog.3")); //$NON-NLS-1$ + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = 4; + b_add2lang.setLayoutData(gd); + if (!newAction) { + b_add2lang.setVisible(false); txt1.setEnabled(false); // don't change name } @@ -118,7 +129,8 @@ public class SymbolDialog extends AbstractPropertyDialog { if (e.widget.equals(b_ok)) { super.text1 = txt1.getText(); super.text2 = txt2.getText(); - check1 = b_add2all.getSelection(); + check1 = b_add2conf.getSelection(); + check3 = b_add2lang.getSelection(); result = true; shell.dispose(); } else if (e.widget.equals(b_ko)) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java index 982e83b068c..ab962b9c065 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java @@ -37,7 +37,8 @@ public class SymbolTab extends AbstractLangsListTab { usercomp.getShell(), true, UIMessages.getString("SymbolTab.2"), EMPTY_STR, EMPTY_STR, getResDesc()); //$NON-NLS-1$ if (dlg.open() && dlg.text1.trim().length() > 0 ) { - toAll = dlg.check1; + toAllCfgs = dlg.check1; + toAllLang = dlg.check3; return new CMacroEntry(dlg.text1, dlg.text2, 0); } else return null;