1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug #182450 : Multi-config

This commit is contained in:
Oleg Krasilnikov 2008-01-29 14:49:58 +00:00
parent 4f17acd8ad
commit bb3803a605
20 changed files with 175 additions and 148 deletions

View file

@ -22,7 +22,7 @@ public interface ICfgScannerConfigBuilderInfo2Set {
void setPerRcTypeDiscovery(boolean on);
Map getInfoMap();
Map<CfgInfoContext, IScannerConfigBuilderInfo2> getInfoMap();
CfgInfoContext[] getContexts();

View file

@ -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<Object> comparator = null;
public static Comparator getInstance() {
public static Comparator<Object> getInstance() {
if (comparator == null)
comparator = new BuildListComparator();
return comparator;

View file

@ -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<ts.length; i++) {
ArrayList lst = new ArrayList(fCfgs.length);
String ext = ts[i].getDefaultInputExtension();
for (int j=0; j<fCfgs.length; j++) {
ITool t = fCfgs[j].getToolFromInputExtension(ext);
if (t != null)
lst.add(t);
}
if (lst.size() > 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<fCfgs.length; i++)
boolean isFolder = true;
for (int i=0; i<fCfgs.length; i++) {
ris[i] = fCfgs[i].getResourceInfo(path, exactPath);
if (! (ris[i] instanceof IFolderInfo))
isFolder = false;
}
if (isFolder) {
IFolderInfo fis[] = new IFolderInfo[ris.length];
System.arraycopy(ris, 0, fis, 0, ris.length);
return new MultiFolderInfo(fis, this);
}
return new MultiResourceInfo(ris, this);
}
@ -600,7 +593,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getResourceInfos()
*/
public IResourceInfo[] getResourceInfos() {
ArrayList ri = new ArrayList();
ArrayList<IResourceInfo> ri = new ArrayList<IResourceInfo>();
for (int i=0; i<fCfgs.length; i++) {
IResourceInfo[] ris = fCfgs[i].getResourceInfos();
ri.addAll(Arrays.asList(ris));

View file

@ -47,53 +47,53 @@ public class MultiFolderInfo extends MultiResourceInfo implements IFolderInfo {
}
public ITool[] getFilteredTools() {
return ((IFolderInfo)fRis[0]).getFilteredTools();
return ((IFolderInfo)fRis[curr]).getFilteredTools();
}
public CFolderData getFolderData() {
return ((IFolderInfo)fRis[0]).getFolderData();
return ((IFolderInfo)fRis[curr]).getFolderData();
}
public String getOutputExtension(String resourceExtension) {
return ((IFolderInfo)fRis[0]).getOutputExtension(resourceExtension);
return ((IFolderInfo)fRis[curr]).getOutputExtension(resourceExtension);
}
public ITool getTool(String id) {
return ((IFolderInfo)fRis[0]).getTool(id);
return ((IFolderInfo)fRis[curr]).getTool(id);
}
public IToolChain getToolChain() {
return ((IFolderInfo)fRis[0]).getToolChain();
return ((IFolderInfo)fRis[curr]).getToolChain();
}
public IModificationStatus getToolChainModificationStatus(ITool[] removed,
ITool[] added) {
return ((IFolderInfo)fRis[0]).getToolChainModificationStatus(removed, added);
return ((IFolderInfo)fRis[curr]).getToolChainModificationStatus(removed, added);
}
public ITool getToolFromInputExtension(String sourceExtension) {
return ((IFolderInfo)fRis[0]).getToolFromInputExtension(sourceExtension);
return ((IFolderInfo)fRis[curr]).getToolFromInputExtension(sourceExtension);
}
public ITool getToolFromOutputExtension(String extension) {
return ((IFolderInfo)fRis[0]).getToolFromOutputExtension(extension);
return ((IFolderInfo)fRis[curr]).getToolFromOutputExtension(extension);
}
public ITool[] getToolsBySuperClassId(String id) {
return ((IFolderInfo)fRis[0]).getToolsBySuperClassId(id);
return ((IFolderInfo)fRis[curr]).getToolsBySuperClassId(id);
}
public boolean isHeaderFile(String ext) {
return ((IFolderInfo)fRis[0]).isHeaderFile(ext);
return ((IFolderInfo)fRis[curr]).isHeaderFile(ext);
}
public boolean isToolChainCompatible(IToolChain ch) {
return ((IFolderInfo)fRis[0]).isToolChainCompatible(ch);
return ((IFolderInfo)fRis[curr]).isToolChainCompatible(ch);
}
public void modifyToolChain(ITool[] removed, ITool[] added)
throws BuildException {
((IFolderInfo)fRis[0]).modifyToolChain(removed, added);
((IFolderInfo)fRis[curr]).modifyToolChain(removed, added);
}
}

View file

@ -38,7 +38,7 @@ public class MultiResourceInfo extends MultiItemsHolder implements
private static final int MODE_COMMAND = 5;
protected IResourceInfo[] fRis = null;
private int activeCfg = 0;
protected int curr = 0;
IConfiguration parent = null;
public MultiResourceInfo(IResourceInfo[] ris, IConfiguration _parent) {
@ -49,7 +49,7 @@ public class MultiResourceInfo extends MultiItemsHolder implements
continue;
Configuration cfg = (Configuration)fRis[i].getParent();
if (cfg.getConfigurationDescription().isActive()) {
activeCfg = i;
curr = i;
break;
}
}
@ -69,14 +69,14 @@ public class MultiResourceInfo extends MultiItemsHolder implements
* @see org.eclipse.cdt.managedbuilder.core.IResourceInfo#getCLanguageDatas()
*/
public CLanguageData[] getCLanguageDatas() {
return fRis[activeCfg].getCLanguageDatas();
return fRis[curr].getCLanguageDatas();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IResourceInfo#getKind()
*/
public int getKind() {
return fRis[activeCfg].getKind();
return fRis[curr].getKind();
}
/* (non-Javadoc)
@ -90,7 +90,7 @@ public class MultiResourceInfo extends MultiItemsHolder implements
* @see org.eclipse.cdt.managedbuilder.core.IResourceInfo#getPath()
*/
public IPath getPath() {
return fRis[activeCfg].getPath();
return fRis[curr].getPath();
}
/* (non-Javadoc)
@ -98,14 +98,14 @@ public class MultiResourceInfo extends MultiItemsHolder implements
*/
public CResourceData getResourceData() {
System.out.println("Strange call: MultiResourceInfo.getResourceData()"); //$NON-NLS-1$
return fRis[activeCfg].getResourceData();
return fRis[curr].getResourceData();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IResourceInfo#getTools()
*/
public ITool[] getTools() {
return fRis[activeCfg].getTools();
return fRis[curr].getTools();
}
/* (non-Javadoc)
@ -307,42 +307,42 @@ public class MultiResourceInfo extends MultiItemsHolder implements
* @see org.eclipse.cdt.managedbuilder.core.IResourceInfo#supportsBuild(boolean)
*/
public boolean supportsBuild(boolean managed) {
return fRis[activeCfg].supportsBuild(managed);
return fRis[curr].supportsBuild(managed);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getBaseId()
*/
public String getBaseId() {
return fRis[activeCfg].getBaseId();
return fRis[curr].getBaseId();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getId()
*/
public String getId() {
return fRis[activeCfg].getId();
return fRis[curr].getId();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getManagedBuildRevision()
*/
public String getManagedBuildRevision() {
return fRis[activeCfg].getManagedBuildRevision();
return fRis[curr].getManagedBuildRevision();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getName()
*/
public String getName() {
return fRis[activeCfg].getName();
return fRis[curr].getName();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getVersion()
*/
public PluginVersionIdentifier getVersion() {
return fRis[activeCfg].getVersion();
return fRis[curr].getVersion();
}
/* (non-Javadoc)
@ -358,7 +358,7 @@ public class MultiResourceInfo extends MultiItemsHolder implements
}
public boolean isRoot() {
return ((ResourceInfo)fRis[activeCfg]).isRoot();
return ((ResourceInfo)fRis[curr]).isRoot();
}
}

View file

@ -32,6 +32,7 @@ import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.MultiResourceInfo;
import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
import org.eclipse.cdt.ui.newui.AbstractPage;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.DirectoryFieldEditor;
@ -47,12 +48,14 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.PlatformUI;
public class BuildOptionSettingsUI extends AbstractToolSettingUI {
private Map fieldsMap = new HashMap();
private Map<String, FieldEditor> fieldsMap =
new HashMap<String, FieldEditor>();
private IOptionCategory category;
private IHoldsOptions optionHolder;
private IHoldsOptions[] ohs;
private int curr;
private Map fieldEditorsToParentMap = new HashMap();
private Map<FieldEditor, Composite> fieldEditorsToParentMap =
new HashMap<FieldEditor, Composite>();
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<ITool> lst = new ArrayList<ITool>();
for (int i=0; i<ris.length; i++) {
ITool[] ts = ris[i].getTools();
for (int j=0; j<ts.length; j++) {
@ -182,7 +185,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
// in the plugin.xml file) in the UI Combobox. This refrains the user from selecting an
// invalid value and avoids issuing an error message.
String[] enumNames = opt.getApplicableValues();
Vector enumValidList = new Vector();
Vector<String> enumValidList = new Vector<String>();
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<String>)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<FieldEditor> fieldsList = fieldsMap.values();
Iterator<FieldEditor> 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<FieldEditor> 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<String> enumValidList = new Vector<String>();
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;
}

View file

@ -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<ITool> list = new ArrayList<ITool>();
ITool tools[] = rcConfig.getTools();
for (int i = 0; i < tools.length; i++) {

View file

@ -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<String> fIncorrectlyDefinedMacrosNames = new HashSet<String>();
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<ICdtVariable> 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<ICdtVariable> lst = new ArrayList<ICdtVariable>(_vars.length);
ICdtVariable[] uvars = vars.getMacros();
for (int i=0; i<uvars.length; i++) {
lst.add(uvars[i]);
@ -517,7 +518,7 @@ public class CPropertyVarsTab extends AbstractCPropertyTab {
}
}
ArrayList list = new ArrayList(_vars.length);
ArrayList<ICdtVariable> list = new ArrayList<ICdtVariable>(_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<Object> {
public int compare(Object a0, Object a1) {
if (a0 == null || a1 == null)

View file

@ -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<CfgInfoContext, IScannerConfigBuilderInfo2> m1 = cbi1.getInfoMap();
Map<CfgInfoContext, IScannerConfigBuilderInfo2> 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<CfgInfoContext, IScannerConfigBuilderInfo2> cfgInfoMap = cbi.getInfoMap();
HashMap<InfoContext, Object> baseCopy = new HashMap<InfoContext, Object>(baseInfoMap);
List<CfgInfoContext> list = new ArrayList<CfgInfoContext>();
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<Object> l1, List<Object> 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<Object> 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();

View file

@ -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<String> list = new ArrayList<String>();
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()]);
}
/**

View file

@ -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<IConfiguration> lst = new ArrayList<IConfiguration>();
for (int i = 0; i < descs.length; ++i) {
cfgds[i] = ManagedBuildManager.getConfigurationForDescription(descs[i]);
IConfiguration cfg = cfgds[i];

View file

@ -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<String>() {
public int compare(final String a, final String b) {
final String strA = a.toUpperCase();
final String strB = b.toUpperCase();
return collator.compare(strA,strB);
}
});

View file

@ -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<IToolChain> list = new ArrayList<IToolChain>();
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<IBuilder> list = new ArrayList<IBuilder>();
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<ITool> list = new ArrayList<ITool>();
IFileInfoModification fim = (IFileInfoModification)mod;
if (real != null) { // Current tool exists

View file

@ -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<ToolListElement> elementList = new ArrayList<ToolListElement>();
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<ToolListElement> elementList = new ArrayList<ToolListElement>();
if (info != null) {
ITool[] tools = null;
if(info instanceof IFolderInfo){

View file

@ -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<ToolListElement> 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<ToolListElement>();
childElements.add(element);
}
}

View file

@ -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<ITool> left, right;
public ArrayList added, removed;
public ArrayList<ITool> 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<ITool>();
removed = new ArrayList<ITool>();
left = new ArrayList<ITool>();
right = new ArrayList<ITool>();
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<all.length; i++) {
if (all[i] != null && t.matches(all[i])) {
@ -432,9 +430,7 @@ public class ToolSelectionDialog extends Dialog {
if (!exists) removed.add(t);
add(t, t1, !exists);
}
it = right.iterator();
while(it.hasNext()) {
ITool t = (ITool)it.next();
for (ITool t : right) {
boolean exists = false;
for (int i=0; i<used.length; i++) {
if (t.matches(used[i])) {
@ -458,7 +454,7 @@ public class ToolSelectionDialog extends Dialog {
if ((c & IModificationStatus.TOOLS_CONFLICT) != 0) {
s = s + Messages.getString("ToolSelectionDialog.7"); //$NON-NLS-1$
ITool[][] tools = st.getToolsConflicts();
List conflictTools = new ArrayList();
List<String> conflictTools = new ArrayList<String>();
for (int k=0; k<t2.getItemCount(); k++) {
TableItem ti = t2.getItem(k);
ITool t = (ITool)ti.getData();
@ -474,10 +470,10 @@ public class ToolSelectionDialog extends Dialog {
}
}
//bug 189229 - provide more information in the error message for accessibility
Iterator iterator = conflictTools.iterator();
s = s+" "+ (String)iterator.next(); //$NON-NLS-1$
Iterator<String> 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) {

View file

@ -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))

View file

@ -67,7 +67,7 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
/*
* Bookeeping variables
*/
private Map configToPageListMap;
private Map<String, List<AbstractToolSettingUI>> 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<String, List<AbstractToolSettingUI>>();
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<AbstractToolSettingUI> pages = getPagesForConfig();
ListIterator<AbstractToolSettingUI> 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<AbstractToolSettingUI> pages = getPagesForConfig();
ListIterator<AbstractToolSettingUI> 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<String>)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<AbstractToolSettingUI> getPagesForConfig() {
if (getCfg() == null) return null;
List pages = (List) configToPageListMap.get(getCfg().getId());
List<AbstractToolSettingUI> pages = (List<AbstractToolSettingUI>) configToPageListMap.get(getCfg().getId());
if (pages == null) {
pages = new ArrayList();
pages = new ArrayList<AbstractToolSettingUI>();
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<AbstractToolSettingUI> pages = getPagesForConfig();
if (pages == null) return;
ListIterator iter = pages.listIterator();
ListIterator<AbstractToolSettingUI> 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<AbstractToolSettingUI> pages = getPagesForConfig();
// Make sure we have something to work on
if (pages == null) {
// Nothing to do
return false;
}
ListIterator iter = pages.listIterator();
ListIterator<AbstractToolSettingUI> iter = pages.listIterator();
while (iter.hasNext()) {
AbstractToolSettingUI page = (AbstractToolSettingUI) iter.next();
if (page == null) continue;

View file

@ -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<Object> {
private static Comparator<Object> comparator = null;
public static Comparator getInstance() {
public static Comparator<Object> getInstance() {
if (comparator == null)
comparator = new CDTListComparator();
return comparator;

View file

@ -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;
}
}
}