From bb3803a6053b1736593f2c57c696cd14be126b7d Mon Sep 17 00:00:00 2001 From: Oleg Krasilnikov Date: Tue, 29 Jan 2008 14:49:58 +0000 Subject: Bug #182450 : Multi-config --- .../ICfgScannerConfigBuilderInfo2Set.java | 2 +- .../managedbuilder/core/BuildListComparator.java | 6 +-- .../internal/core/MultiConfiguration.java | 29 +++++-------- .../internal/core/MultiFolderInfo.java | 24 +++++------ .../internal/core/MultiResourceInfo.java | 28 ++++++------- .../ui/properties/BuildOptionSettingsUI.java | 27 ++++++------ .../ui/properties/BuildStepsTab.java | 4 +- .../ui/properties/CPropertyVarsTab.java | 13 +++--- .../managedbuilder/ui/properties/DiscoveryTab.java | 29 ++++++------- .../ui/properties/FileListControlFieldEditor.java | 8 ++-- .../managedbuilder/ui/properties/NewCfgDialog.java | 4 +- .../managedbuilder/ui/properties/NewVarDialog.java | 10 ++--- .../ui/properties/ToolChainEditTab.java | 8 ++-- .../ui/properties/ToolListContentProvider.java | 6 +-- .../ui/properties/ToolListElement.java | 6 +-- .../ui/properties/ToolSelectionDialog.java | 30 ++++++------- .../ui/properties/ToolSettingsPrefStore.java | 3 +- .../ui/properties/ToolSettingsTab.java | 29 ++++++------- .../cdt/core/model/util/CDTListComparator.java | 8 ++-- .../eclipse/cdt/ui/newui/AbstractCPropertyTab.java | 49 +++++++++++++++++++--- 20 files changed, 175 insertions(+), 148 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/ICfgScannerConfigBuilderInfo2Set.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/ICfgScannerConfigBuilderInfo2Set.java index eb431944ec5..e816375c5a2 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/ICfgScannerConfigBuilderInfo2Set.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/ICfgScannerConfigBuilderInfo2Set.java @@ -22,7 +22,7 @@ public interface ICfgScannerConfigBuilderInfo2Set { void setPerRcTypeDiscovery(boolean on); - Map getInfoMap(); + Map getInfoMap(); CfgInfoContext[] getContexts(); diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/BuildListComparator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/BuildListComparator.java index ad4993d8cd4..c2386459370 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/BuildListComparator.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/BuildListComparator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Intel Corporation and others. + * Copyright (c) 2007, 2008 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,9 +21,9 @@ import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue; public class BuildListComparator extends CDTListComparator { private static final String EMPTY = ""; //$NON-NLS-1$ - private static Comparator comparator = null; + private static Comparator comparator = null; - public static Comparator getInstance() { + public static Comparator getInstance() { if (comparator == null) comparator = new BuildListComparator(); return comparator; diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MultiConfiguration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MultiConfiguration.java index 9c7867558c8..01b563acc2b 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MultiConfiguration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MultiConfiguration.java @@ -397,22 +397,6 @@ public class MultiConfiguration extends MultiItemsHolder implements */ public ITool[] getFilteredTools() { ITool[] ts = curr().getFilteredTools(); - /* - ITool[] ms = new ITool[ts.length]; - for (int i=0; i 1) - ms[i] = (ITool)new MultiTool(lst, curr); - else - ms[i] = ts[i]; - } - */ return ts; } @@ -583,8 +567,17 @@ public class MultiConfiguration extends MultiItemsHolder implements */ public IResourceInfo getResourceInfo(IPath path, boolean exactPath) { IResourceInfo ris[] = new IResourceInfo[fCfgs.length]; - for (int i=0; i ri = new ArrayList(); for (int i=0; i fieldsMap = + new HashMap(); private IOptionCategory category; private IHoldsOptions optionHolder; private IHoldsOptions[] ohs; private int curr; - private Map fieldEditorsToParentMap = new HashMap(); + private Map fieldEditorsToParentMap = + new HashMap(); public BuildOptionSettingsUI(AbstractCBuildPropertyTab page, IResourceInfo info, IHoldsOptions optionHolder, @@ -66,7 +69,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI { IResourceInfo[] ris = (IResourceInfo[])mri.getItems(); String id = category.getId(); String ext = ((ITool)optionHolder).getDefaultInputExtension(); - ArrayList lst = new ArrayList(); + ArrayList lst = new ArrayList(); for (int i=0; i enumValidList = new Vector(); for (int i = 0; i < enumNames.length; ++i) { if (opt.getValueHandler().isEnumValueAppropriate(config, opt.getOptionHolder(), opt, opt.getValueHandlerExtraArgument(), enumNames[i])) { @@ -247,6 +250,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI { /* (non-Javadoc) * @see org.eclipse.jface.preference.IPreferencePage#performOk() */ + @SuppressWarnings("unchecked") public boolean performOk() { // Write the field editor contents out to the preference store boolean ok = super.performOk(); @@ -323,7 +327,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI { case IOption.UNDEF_LIBRARY_PATHS: case IOption.UNDEF_LIBRARY_FILES: case IOption.UNDEF_MACRO_FILES: - String[] listVal = (String[])((List)clonedOption.getValue()).toArray(new String[0]); + String[] listVal = (String[])((List)clonedOption.getValue()).toArray(new String[0]); setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption, listVal); // Reset the preference store since the Id may have changed @@ -391,8 +395,8 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI { } } - Collection fieldsList = fieldsMap.values(); - Iterator iter = fieldsList.iterator(); + Collection fieldsList = fieldsMap.values(); + Iterator iter = fieldsList.iterator(); while (iter.hasNext()) { FieldEditor editor = (FieldEditor) iter.next(); if (editor instanceof TriStateBooleanFieldEditor) @@ -530,7 +534,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI { } } - Iterator iter = fieldsMap.values().iterator(); + Iterator iter = fieldsMap.values().iterator(); while (iter.hasNext()) { FieldEditor editor = (FieldEditor) iter.next(); if(id == null || !id.equals(editor.getPreferenceName())) @@ -572,7 +576,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI { boolean selectNewEnum = true; boolean selectDefault = false; - Vector enumValidList = new Vector(); + Vector enumValidList = new Vector(); for (int i = 0; i < enumNames.length; ++i) { if (opt.getValueHandler().isEnumValueAppropriate(config, opt.getOptionHolder(), opt, opt.getValueHandlerExtraArgument(), enumNames[i])) { @@ -629,7 +633,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI { protected void valueChanged(boolean oldValue, boolean newValue) { // TODO: uncomment before M5 //if (button.getGrayed()) - // button.setGrayed(false); + AbstractCPropertyTab.setGrayed(button, false); super.valueChanged(!newValue, newValue); } protected void doLoad() { @@ -654,8 +658,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI { if (vals[0] > 0) gray = true; } - // TODO: uncomment before M5 - // button.setGrayed(gray); + AbstractCPropertyTab.setGrayed(button, gray); button.setSelection(value); return; } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildStepsTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildStepsTab.java index 73a1db4656c..ee3cc5323c9 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildStepsTab.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildStepsTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Intel Corporation and others. + * Copyright (c) 2007, 2008 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -247,7 +247,7 @@ public class BuildStepsTab extends AbstractCBuildPropertyTab { } private ITool[] getRcbsTools(IResourceInfo rcConfig){ - List list = new ArrayList(); + List list = new ArrayList(); ITool tools[] = rcConfig.getTools(); for (int i = 0; i < tools.length; i++) { diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/CPropertyVarsTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/CPropertyVarsTab.java index 073b02d0ae5..1f647abb9a2 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/CPropertyVarsTab.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/CPropertyVarsTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 Intel Corporation and others. + * Copyright (c) 2005 - 2008 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -126,7 +126,7 @@ public class CPropertyVarsTab extends AbstractCPropertyTab { }; private boolean fShowSysMacros = false; - private Set fIncorrectlyDefinedMacrosNames = new HashSet(); + private Set fIncorrectlyDefinedMacrosNames = new HashSet(); private static final int CONTEXT = ICoreVariableContextInfo.CONTEXT_CONFIGURATION; private TableViewer tv; @@ -325,9 +325,10 @@ public class CPropertyVarsTab extends AbstractCPropertyTab { /* * returnes the selected user-defined macros */ + @SuppressWarnings("unchecked") private ICdtVariable[] getSelectedUserMacros(){ if(tv == null) return null; - List list = ((IStructuredSelection)tv.getSelection()).toList(); + List list = ((IStructuredSelection)tv.getSelection()).toList(); return (ICdtVariable[])list.toArray(new ICdtVariable[list.size()]); } @@ -495,7 +496,7 @@ public class CPropertyVarsTab extends AbstractCPropertyTab { if (_vars == null) return; if (cfgd == null) { if (fShowSysMacros) { - List lst = new ArrayList(_vars.length); + List lst = new ArrayList(_vars.length); ICdtVariable[] uvars = vars.getMacros(); for (int i=0; i list = new ArrayList(_vars.length); for(int i = 0; i < _vars.length; i++){ if(_vars[i] != null && (fShowSysMacros || isUserVar(_vars[i]))) list.add(_vars[i]); @@ -633,7 +634,7 @@ public class CPropertyVarsTab extends AbstractCPropertyTab { return page.isForProject() || page.isForPrefs(); } - private static class EnvCmp implements Comparator { + private static class EnvCmp implements Comparator { public int compare(Object a0, Object a1) { if (a0 == null || a1 == null) diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/DiscoveryTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/DiscoveryTab.java index 7fcdda0bdce..fce7ff52b4a 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/DiscoveryTab.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/DiscoveryTab.java @@ -445,11 +445,9 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(getCfg(dst.getConfiguration())); cbi2.setPerRcTypeDiscovery(cbi1.isPerRcTypeDiscovery()); - Map m1 = cbi1.getInfoMap(); - Map m2 = cbi2.getInfoMap(); - Iterator it2 = m2.keySet().iterator(); - while (it2.hasNext()) { - CfgInfoContext ic = (CfgInfoContext)it2.next(); + Map m1 = cbi1.getInfoMap(); + Map m2 = cbi2.getInfoMap(); + for (CfgInfoContext ic : m2.keySet()) { if (m1.keySet().contains(ic)) { IScannerConfigBuilderInfo2 bi1 = (IScannerConfigBuilderInfo2)m1.get(ic); try { @@ -503,11 +501,10 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf if(cbi == null || baseInfoMap == null) return new ArrayList(0); - Map cfgInfoMap = cbi.getInfoMap(); - HashMap baseCopy = new HashMap(baseInfoMap); - List list = new ArrayList(); - for(Iterator iter = cfgInfoMap.entrySet().iterator(); iter.hasNext();){ - Map.Entry entry = (Map.Entry)iter.next(); + Map cfgInfoMap = cbi.getInfoMap(); + HashMap baseCopy = new HashMap(baseInfoMap); + List list = new ArrayList(); + for(Map.Entry entry : cfgInfoMap.entrySet()){ CfgInfoContext cic = (CfgInfoContext)entry.getKey(); InfoContext c = cic.toInfoContext(); if(c == null) @@ -525,8 +522,7 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf if(baseCopy.size() != 0){ IConfiguration cfg = cbi.getConfiguration(); - for(Iterator iter = baseCopy.keySet().iterator(); iter.hasNext();){ - InfoContext c = (InfoContext)iter.next(); + for(InfoContext c : baseCopy.keySet()){ CfgInfoContext cic = CfgInfoContext.fromInfoContext(cfg, c); if(cic != null) list.add(cic); @@ -557,7 +553,7 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf return true; } - private boolean listEqual(List l1, List l2) { + private boolean listEqual(List l1, List l2) { if (l1 == null && l2 == null) return true; if (l2 == null || l2 == null) return false; if (l1.size() != l2.size()) return false; @@ -565,7 +561,7 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf // since it's most probable, try it first. if (l1.equals(l2)) return true; // order may differ... - Iterator it = l1.iterator(); + Iterator it = l1.iterator(); while (it.hasNext()) if (!l2.contains(it.next())) return false; return true; @@ -592,10 +588,9 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf if (page.isMultiCfg()) return; cbi.setPerRcTypeDiscovery(true); - Iterator it = cbi.getInfoMap().keySet().iterator(); - while (it.hasNext()) { + for (CfgInfoContext cic : cbi.getInfoMap().keySet()) { try { - cbi.applyInfo((CfgInfoContext)it.next(), null); + cbi.applyInfo(cic, null); } catch (CoreException e) {} } updateData(); diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControlFieldEditor.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControlFieldEditor.java index 5428e1850ca..a8beea1d463 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControlFieldEditor.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControlFieldEditor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 BitMethods Inc and others. + * Copyright (c) 2004, 2008 BitMethods Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -293,11 +293,11 @@ public class FileListControlFieldEditor extends FieldEditor { private String[] parseString(String stringList) { StringTokenizer tokenizer = new StringTokenizer(stringList, DEFAULT_SEPERATOR); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList(); while (tokenizer.hasMoreElements()) { - list.add(tokenizer.nextElement()); + list.add((String)tokenizer.nextElement()); } - return (String[]) list.toArray(new String[list.size()]); + return list.toArray(new String[list.size()]); } /** diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewCfgDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewCfgDialog.java index f9f507f23fc..705000c95d3 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewCfgDialog.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewCfgDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Intel Corporation and others. + * Copyright (c) 2007, 2008 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -332,7 +332,7 @@ public class NewCfgDialog implements INewCfgDialog { des = prj; ICConfigurationDescription[] descs = des.getConfigurations(); cfgds = new IConfiguration[descs.length]; - ArrayList lst = new ArrayList(); + ArrayList lst = new ArrayList(); for (int i = 0; i < descs.length; ++i) { cfgds[i] = ManagedBuildManager.getConfigurationForDescription(descs[i]); IConfiguration cfg = cfgds[i]; diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewVarDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewVarDialog.java index ef7528ab06a..ffd2605cbb3 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewVarDialog.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewVarDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 Intel Corporation and others. + * Copyright (c) 2005 - 2008 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -260,10 +260,10 @@ public class NewVarDialog extends Dialog { for(int i = 0; i < vars.length; i++) names[i] = vars[i].getName(); final Collator collator = Collator.getInstance(); - Arrays.sort(names, new Comparator() { - public int compare(final Object a, final Object b) { - final String strA = ((String)a).toUpperCase(); - final String strB = ((String)b).toUpperCase(); + Arrays.sort(names, new Comparator() { + public int compare(final String a, final String b) { + final String strA = a.toUpperCase(); + final String strB = b.toUpperCase(); return collator.compare(strA,strB); } }); diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolChainEditTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolChainEditTab.java index ec9253a20f7..5dc8897a750 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolChainEditTab.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolChainEditTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Intel Corporation and others. + * Copyright (c) 2007, 2008 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -222,7 +222,7 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab { c_toolchain.removeAll(); boolean isMng = cfg.getBuilder().isManagedBuildOn(); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList(); IToolChain[] tcs = r_tcs; if (b_dispCompatible.getSelection() && (ri instanceof IFolderInfo)) { @@ -264,7 +264,7 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab { IBuilder b = ManagedBuildManager.getRealBuilder(cfg.getBuilder()); int pos = -1; c_builder.removeAll(); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList(); IBuilder[] bs = r_bs; @@ -384,7 +384,7 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab { private boolean updateCompatibleTools(ITool real) { boolean result = false; - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList(); IFileInfoModification fim = (IFileInfoModification)mod; if (real != null) { // Current tool exists diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java index 2ada54c9a65..e82264d16b8 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2007 IBM Corporation and others. + * Copyright (c) 2002 - 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -45,7 +45,7 @@ public class ToolListContentProvider implements ITreeContentProvider{ private ToolListElement[] createElements(IConfiguration config) { IOptionCategory toolChainCategories[]; ITool filteredTools[]; - List elementList = new ArrayList(); + List elementList = new ArrayList(); if (config != null) { // Get the the option categories of the toolChain IToolChain toolChain = config.getToolChain(); @@ -69,7 +69,7 @@ public class ToolListContentProvider implements ITreeContentProvider{ } private ToolListElement[] createElements(IResourceInfo info) { - List elementList = new ArrayList(); + List elementList = new ArrayList(); if (info != null) { ITool[] tools = null; if(info instanceof IFolderInfo){ diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListElement.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListElement.java index 1bc58051480..9f3f75630c5 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListElement.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListElement.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 Intel Corporation and others. + * Copyright (c) 2006, 2008 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,7 +33,7 @@ public class ToolListElement { * Bookeeping variables */ private ToolListElement parent = null; - private List childElements = null; + private List childElements = null; private IHoldsOptions optionHolder = null; private IOptionCategory optionCategory = null; @@ -116,7 +116,7 @@ public class ToolListElement { public void addChildElement(ToolListElement element) { if (childElements == null) - childElements = new ArrayList(); + childElements = new ArrayList(); childElements.add(element); } } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolSelectionDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolSelectionDialog.java index cdd899fcc28..afaf6abcee9 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolSelectionDialog.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolSelectionDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Intel Corporation and others. + * Copyright (c) 2007, 2008 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -64,9 +64,9 @@ public class ToolSelectionDialog extends Dialog { private Button b_add, b_del, b_rep, b_all; private CLabel errorLabel, l1; private Text txt2; - private ArrayList left, right; + private ArrayList left, right; - public ArrayList added, removed; + public ArrayList added, removed; public ITool[] all, used; public IFolderInfo fi; public IToolListModification mod = null; @@ -92,10 +92,10 @@ public class ToolSelectionDialog extends Dialog { gd.heightHint = 300; composite.setLayoutData(gd); - added = new ArrayList(); - removed = new ArrayList(); - left = new ArrayList(); - right = new ArrayList(); + added = new ArrayList(); + removed = new ArrayList(); + left = new ArrayList(); + right = new ArrayList(); Composite c1 = new Composite(composite, SWT.NONE); c1.setLayoutData(new GridData(GridData.FILL_BOTH)); @@ -419,9 +419,7 @@ public class ToolSelectionDialog extends Dialog { Collections.sort(left, BuildListComparator.getInstance()); - Iterator it = left.iterator(); - while(it.hasNext()) { - ITool t = (ITool)it.next(); + for (ITool t : left) { boolean exists = false; for (int i=0; i conflictTools = new ArrayList(); for (int k=0; k iterator = conflictTools.iterator(); + s = s+" "+ iterator.next(); //$NON-NLS-1$ while (iterator.hasNext()) { - s = s + ", " + (String)iterator.next(); //$NON-NLS-1$ + s = s + ", " + iterator.next(); //$NON-NLS-1$ } } if ((c & IModificationStatus.TOOLS_DONT_SUPPORT_MANAGED_BUILD) != 0) { diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolSettingsPrefStore.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolSettingsPrefStore.java index 26e921c6680..0fb5fea9531 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolSettingsPrefStore.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolSettingsPrefStore.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 Intel Corporation and others. + * Copyright (c) 2005, 2008 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -139,6 +139,7 @@ public class ToolSettingsPrefStore implements IPreferenceStore { return getDefaultLong(name); } + @SuppressWarnings("unchecked") public String getString(String name) { if(optCategory instanceof Tool){ if(optCategory.getId().equals(name)) diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolSettingsTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolSettingsTab.java index 5b41101ab50..1e37a9035cc 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolSettingsTab.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolSettingsTab.java @@ -67,7 +67,7 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe /* * Bookeeping variables */ - private Map configToPageListMap; + private Map> configToPageListMap; private IPreferenceStore settingsStore; private AbstractToolSettingUI currentSettingsPage; private ToolListElement selectedElement; @@ -80,7 +80,7 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe super.createControls(par); usercomp.setLayout(new GridLayout()); - configToPageListMap = new HashMap(); + configToPageListMap = new HashMap>(); settingsStore = ToolSettingsPrefStore.getDefault(); // Create the sash form @@ -157,8 +157,8 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe currentSettingsPage = null; // Create a new settings page if necessary - List pages = getPagesForConfig(); - ListIterator iter = pages.listIterator(); + List pages = getPagesForConfig(); + ListIterator iter = pages.listIterator(); while (iter.hasNext()) { AbstractToolSettingUI page = (AbstractToolSettingUI) iter.next(); @@ -211,8 +211,8 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe currentSettingsPage = null; // Create a new page if we need one - List pages = getPagesForConfig(); - ListIterator iter = pages.listIterator(); + List pages = getPagesForConfig(); + ListIterator iter = pages.listIterator(); while (iter.hasNext()) { AbstractToolSettingUI page = (AbstractToolSettingUI) iter.next(); if (page.isFor(tool, null)) { @@ -444,6 +444,7 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe } } + @SuppressWarnings("unchecked") private void setOption(IOption op1, IOption op2, IHoldsOptions dst, IResourceInfo res){ try { switch (op1.getValueType()) { @@ -475,7 +476,7 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe case IOption.UNDEF_LIBRARY_PATHS: case IOption.UNDEF_LIBRARY_FILES: case IOption.UNDEF_MACRO_FILES: - String[] data = (String[])((List)op1.getValue()).toArray(new String[0]); + String[] data = (String[])((List)op1.getValue()).toArray(new String[0]); ManagedBuildManager.setOption(res, dst, op2, data); break; default : @@ -536,11 +537,11 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe /* (non-Javadoc) * Answers the list of settings pages for the selected configuration */ - private List getPagesForConfig() { + private List getPagesForConfig() { if (getCfg() == null) return null; - List pages = (List) configToPageListMap.get(getCfg().getId()); + List pages = (List) configToPageListMap.get(getCfg().getId()); if (pages == null) { - pages = new ArrayList(); + pages = new ArrayList(); configToPageListMap.put(getCfg().getId(), pages); } return pages; @@ -554,9 +555,9 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe * Sets the "dirty" state */ public void setDirty(boolean b) { - List pages = getPagesForConfig(); + List pages = getPagesForConfig(); if (pages == null) return; - ListIterator iter = pages.listIterator(); + ListIterator iter = pages.listIterator(); while (iter.hasNext()) { AbstractToolSettingUI page = (AbstractToolSettingUI) iter.next(); if (page == null) continue; @@ -569,13 +570,13 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe */ public boolean isDirty() { // Check each settings page - List pages = getPagesForConfig(); + List pages = getPagesForConfig(); // Make sure we have something to work on if (pages == null) { // Nothing to do return false; } - ListIterator iter = pages.listIterator(); + ListIterator iter = pages.listIterator(); while (iter.hasNext()) { AbstractToolSettingUI page = (AbstractToolSettingUI) iter.next(); if (page == null) continue; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CDTListComparator.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CDTListComparator.java index 510cb1c40f2..c6c5f5008ec 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CDTListComparator.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CDTListComparator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 Intel Corporation and others + * Copyright (c) 2005 - 2008 Intel Corporation and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,10 +17,10 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSetting; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; -public class CDTListComparator implements Comparator { - private static Comparator comparator = null; +public class CDTListComparator implements Comparator { + private static Comparator comparator = null; - public static Comparator getInstance() { + public static Comparator getInstance() { if (comparator == null) comparator = new CDTListComparator(); return comparator; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java index 355769584b9..60ae30598c9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java @@ -10,6 +10,9 @@ *******************************************************************************/ package org.eclipse.cdt.ui.newui; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -70,6 +73,8 @@ import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; * communication way for new CDT model pages and tabs. */ public abstract class AbstractCPropertyTab implements ICPropertyTab { + + public static final Method GRAY_METHOD = getGrayEnabled(); public static final int BUTTON_WIDTH = 120; // used as hint for all push buttons // commonly used button names @@ -322,8 +327,7 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab { setupControl(b, span, mode); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { - // TODO: uncomment before M5 - //((Button)event.widget).setGrayed(false); + setGrayed((Button)event.widget, false); checkPressed(event); }}); return b; @@ -535,22 +539,55 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab { */ public static void setTriSelection(Button b, int state) { switch (state) { - // TODO: uncomment before M5 case TRI_NO: - // b.setGrayed(false); + setGrayed(b, false); b.setSelection(false); break; case TRI_YES: - // b.setGrayed(false); + setGrayed(b, false); b.setSelection(true); break; case TRI_UNKNOWN: b.setSelection(true); - // b.setGrayed(true); + setGrayed(b, true); break; } } + /** + * This method will be simplified after M5 release, + * when Button.setGrayed() method will be accessible. + * In this case, reflection will not be required. + * + * @param b + * @param value + */ + public static void setGrayed(Button b, boolean value) { + // TODO: uncomment before M5 + // b.setGrayed(value); + if (GRAY_METHOD != null) + try { + GRAY_METHOD.invoke(b, new Object[] { new Boolean(value) }); + } + catch (InvocationTargetException e) {} + catch (IllegalAccessException e) {} + } + /** + * This method will be removed after M5 release, + * when Button.setGrayed() will be officially accessible. + * + * @return reference to Button.setGrayed() method + */ + private static Method getGrayEnabled() { + try { + Class cl = Class.forName("org.eclipse.swt.widgets.Button"); //$NON-NLS-1$ + return cl.getMethod("setGrayed", new Class[] { boolean.class }); //$NON-NLS-1$ + } catch (ClassNotFoundException e) { + return null; + } catch (NoSuchMethodException e) { + return null; + } + } } -- cgit v1.2.3