diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java index b7ec2f7d49c..f2a4c4d173c 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2006 Rational Software Corporation and others. + * Copyright (c) 2003, 2008 Rational Software 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 interface IManagedBuildInfo { * * @return */ - public List getTargets(); + public List getTargets(); /** * Returns a String containing the command-line invocation diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java index 570c3652993..4ac5c952836 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java @@ -195,7 +195,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI private static boolean projectTypesLoading = false; // Project types defined in the manifest files public static SortedMap projectTypeMap; - private static List projectTypes; + private static List projectTypes; // Early configuration initialization extension elements private static List startUpConfigElements; // Configurations defined in the manifest files @@ -313,7 +313,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI } // Get the project types for this project and all referenced projects - List definedTypes = null; + List definedTypes = null; // To Do // Create the array and copy the elements over @@ -329,7 +329,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI if (definedTypes != null) for (int i = 0; i < definedTypes.size(); ++i) - types[n++] = (IProjectType)definedTypes.get(i); + types[n++] = definedTypes.get(i); return types; } @@ -573,8 +573,8 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI IManagedBuildInfo buildInfo = getBuildInfo(resource); if (buildInfo != null) { - List targets = buildInfo.getTargets(); - return (ITarget[])targets.toArray(new ITarget[targets.size()]); + List targets = buildInfo.getTargets(); + return targets.toArray(new ITarget[targets.size()]); } return emptyTargets; } @@ -930,6 +930,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI * @param config * @param option */ + /* private static void notifyListeners(IConfiguration config, IOption option) { // Continue if change is something that effect the scanner try { @@ -964,7 +965,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI ((IScannerInfoChangeListener)iter.next()).changeNotification(resource, (IScannerInfo)getBuildInfo(resource)); } } - +*/ public static void initializePathEntries(IConfiguration config, IOption option){ try{ if(config.isTemporary() || @@ -1756,7 +1757,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI */ public static void addExtensionProjectType(ProjectType projectType) { if (projectTypes == null) { - projectTypes = new ArrayList(); + projectTypes = new ArrayList(); } projectTypes.add(projectType); @@ -3924,7 +3925,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI if (cfgDes instanceof ICMultiConfigDescription) { ICMultiConfigDescription mcd = (ICMultiConfigDescription)cfgDes; ICConfigurationDescription[] cfds = (ICConfigurationDescription[])mcd.getItems(); - return new MultiConfiguration(cfds, mcd.getStringListMode()); + return new MultiConfiguration(cfds); } CConfigurationData cfgData = cfgDes.getConfigurationData(); diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java index 459a644e5cf..d4bc3badb4b 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java @@ -2551,10 +2551,10 @@ public class Builder extends BuildObject implements IBuilder, IMatchKeyProvider, setDirty(true); } - public Set contributeErrorParsers(Set set){ + public Set contributeErrorParsers(Set set){ if(getErrorParserIds() != null){ if(set == null) - set = new HashSet(); + set = new HashSet(); String ids[] = getErrorParserList(); if(ids.length != 0) diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/FolderInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/FolderInfo.java index 935aa0bae7d..373365ec7c5 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/FolderInfo.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/FolderInfo.java @@ -925,14 +925,12 @@ public class FolderInfo extends ResourceInfo implements IFolderInfo { } private ITool[][] getBestMatches(ITool[] tools1, ITool[] tools2){ - HashSet set = new HashSet(Arrays.asList(tools2)); - List list = new ArrayList(tools1.length); - for(int i = 0; i < tools1.length; i++){ - ITool tool1 = tools1[i]; + HashSet set = new HashSet(Arrays.asList(tools2)); + List list = new ArrayList(tools1.length); + for(ITool tool1 : tools1){ ITool bestMatchTool = null; int num = 0; - for(Iterator iter = set.iterator(); iter.hasNext();){ - ITool tool2 = (ITool)iter.next(); + for(ITool tool2 : set){ int extsNum = getConflictingInputExts(tool1, tool2).length; if(extsNum > num){ bestMatchTool = tool2; 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 10712f62945..4d85ad2eacf 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 @@ -57,9 +57,8 @@ public class MultiConfiguration extends MultiItemsHolder implements protected IConfiguration[] fCfgs = null; private int curr = 0; - public MultiConfiguration(IConfiguration[] cfs, int mode) { + public MultiConfiguration(IConfiguration[] cfs) { fCfgs = cfs; - setStringListMode(mode); for (int i=0; i 0){ + if(MessageDialog.openQuestion(usercomp.getShell(), + UIMessages.getString(DELETE_CONFIRM_TITLE), + UIMessages.getString(DELETE_CONFIRM_MESSAGE))){ + for(int i = 0; i < macros.length; i++){ if (cfgd != null) { - if (dlg.isForAllCfgs) { - ICConfigurationDescription[] cfgs = page.getCfgsEditable(); - for (int k=0; k 0){ - if(MessageDialog.openQuestion(usercomp.getShell(), - UIMessages.getString(DELETE_CONFIRM_TITLE), - UIMessages.getString(DELETE_CONFIRM_MESSAGE))){ - for(int i = 0; i < macros.length; i++){ - if (cfgd != null) { - if (page.isMultiCfg() && cfgd instanceof ICMultiItemsHolder) { - ICConfigurationDescription[] cfs = (ICConfigurationDescription[])((ICMultiItemsHolder)cfgd).getItems(); - for (int k=0; k lst = new ArrayList(_vars.length); @@ -586,7 +634,7 @@ public class CPropertyVarsTab extends AbstractCPropertyTab { return value; } - public void performApply(ICResourceDescription src, ICResourceDescription dst) { + protected void performApply(ICResourceDescription src, ICResourceDescription dst) { if (cfgd != null) {// only for project, not for prefs if (page.isMultiCfg()) { if (src instanceof ICMultiItemsHolder && diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiLanguageSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/MultiLanguageSetting.java similarity index 85% rename from core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiLanguageSetting.java rename to core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/MultiLanguageSetting.java index 9b5bee5737d..6e35af48689 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiLanguageSetting.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/MultiLanguageSetting.java @@ -8,13 +8,11 @@ * Contributors: * Intel Corporation - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.internal.core.settings.model; +package org.eclipse.cdt.core.model; import java.util.Arrays; -import java.util.Comparator; import java.util.List; -import org.eclipse.cdt.core.model.util.CDTListComparator; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSetting; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; @@ -26,8 +24,6 @@ import org.eclipse.cdt.core.settings.model.MultiItemsHolder; * Normally, they should have the same name. */ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguageSetting { - private static final Comparator comp = CDTListComparator.getInstance(); - ICLanguageSetting[] items = null; ICConfigurationDescription cfgd = null; @@ -40,34 +36,18 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#getLanguageId() */ public String getLanguageId() { - System.out.println("Bad multi access: MultiLanguageSetting.getLanguageId()"); return null; // IDs are different. } - private ICLanguageSettingEntry[] conv2LSE(Object[] ob) { - ICLanguageSettingEntry[] se = new ICLanguageSettingEntry[ob.length]; - System.arraycopy(ob, 0, se, 0, ob.length); - return se; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#getResolvedSettingEntries(int) - */ - public ICLanguageSettingEntry[] getResolvedSettingEntries(int kind) { - ICLanguageSettingEntry[][] le = new ICLanguageSettingEntry[items.length][]; - for (int i=0; i getReferenceInfo(); /** * sets the reference information for this configuration, i.e. the information on the projects/configurations @@ -231,7 +231,7 @@ public interface ICConfigurationDescription extends ICSettingContainer, ICSettin * @throws WriteAccessException when the configuration description is read-only * the description is read only if it was queried/returned by the {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)} call */ - void setReferenceInfo(Map refs) throws WriteAccessException; + void setReferenceInfo(Map refs) throws WriteAccessException; /** * returns an array of settings exported by this configuration diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMultiConfigDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMultiConfigDescription.java index d95e2370c46..b099fa155e6 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMultiConfigDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMultiConfigDescription.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 @@ -11,6 +11,6 @@ package org.eclipse.cdt.core.settings.model; public interface ICMultiConfigDescription extends ICConfigurationDescription, ICMultiItemsHolder { - String[] getErrorParserIDs(); + String[][] getErrorParserIDs(); void setErrorParserIDs(String[] s); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMultiFolderDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMultiFolderDescription.java new file mode 100644 index 00000000000..75b56ce456f --- /dev/null +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMultiFolderDescription.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.settings.model; + +import java.util.Comparator; + +public interface ICMultiFolderDescription extends ICFolderDescription { + public ICLanguageSetting[][] getLanguageSettingsM(Comparator comp); +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMultiItemsHolder.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMultiItemsHolder.java index 23a6e0f4ab1..6358f6d03c5 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMultiItemsHolder.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMultiItemsHolder.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 @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.core.settings.model; -import java.util.Comparator; /** * Implementors of this interface are intended @@ -25,74 +24,11 @@ import java.util.Comparator; * */ public interface ICMultiItemsHolder { - /* - * Constants for String list display mode - */ - // display conjunction of lists entries (common ones) - public static final int DMODE_CONJUNCTION = 1; - // display empty list if item's lists are different - public static final int DMODE_EMPTY = 2; - // display all items from all lists (except doubles) - public static final int DMODE_ALL = 4; - // display modes mask - public static final int DMODES = DMODE_CONJUNCTION | DMODE_EMPTY | DMODE_ALL; - /* - * Constants for string list apply mode - */ - // write to all items the list presented now. - public static final int WMODE_CURRENT = 8; - // apply to all items all insertions/deletions made - public static final int WMODE_DIFF = 16; - // write modes mask - public static final int WMODES = WMODE_CURRENT | WMODE_DIFF; - - // default setting - public static final int MODE_DEFAULT = DMODE_CONJUNCTION | WMODE_CURRENT; - - /* - * General purpose objects - */ public static final String EMPTY_STR = ""; - public static final Object[] EMPTY_ARRAY = new Object[0]; - /** * Returns array of items which it holds * @return */ Object[] getItems(); - - /** - * @see DMODE_CONJUNCTION - * @see DMODE_EMPTY - * @see DMODE_ALL - * @see WMODE_DIFF - * @see WMODE_CURRENT - - * @return current string list mode (OR'ed display and write modes) - */ - int getStringListMode(); - - /** - * @see DMODE_CONJUNCTION - * @see DMODE_EMPTY - * @see DMODE_ALL - * @see WMODE_DIFF - * @see WMODE_CURRENT - * - * @param mode: OR'ed display and write modes - */ - void setStringListMode(int mode); - - /* - * A set of methods which form an array of objects - * on a basis of 2-dim array and DISPLAY MODE - */ - String[] getStrListForDisplay(String[][] input); - String[] getStrListForDisplay(String[][] input, int mode); -// Object[] getListForDisplay(Object[][] input); -// Object[] getListForDisplay(Object[][] input, int mode); - Object[] getListForDisplay(Object[][] input, Comparator cmp); -// Object[] getListForDisplay(Object[][] input, int mode, Comparator cmp); - } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/MultiItemsHolder.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/MultiItemsHolder.java index efa56bf20b8..3afba0e19c4 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/MultiItemsHolder.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/MultiItemsHolder.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 @@ -10,12 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.core.settings.model; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.HashSet; - -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.internal.core.settings.model.MultiConfigDescription; /** @@ -23,126 +17,14 @@ import org.eclipse.cdt.internal.core.settings.model.MultiConfigDescription; * */ public abstract class MultiItemsHolder implements ICMultiItemsHolder { - protected int fListMode = MODE_DEFAULT; - /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICMultiItemsHolder#getItems() */ public abstract Object[] getItems(); - /* (non-Javadoc) - * @see org.eclipse.cdt.core.settings.model.ICMultiItemsHolder#getStringListMode() - */ - public int getStringListMode() { - return fListMode; - } - /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICMultiItemsHolder#setStringListMode(int) */ - public void setStringListMode(int mode) { - int a = mode & DMODES; - int b = mode & WMODES; - if (a == DMODES || b == WMODES) { // conflicting settings; - CCorePlugin.log("Wrong string list mode: " + mode); - return; - } - else if (a == 0) // display mode not set - mode |= (fListMode & DMODES); // use existing - else if (b == 0) // write mode not set - mode |= (fListMode & WMODES); // use existing - fListMode = mode & (DMODES | WMODES); - } - - public final String[] getStrListForDisplay(String[][] input) { - return getStrListForDisplay(input, getStringListMode()); - } - - public final String[] getStrListForDisplay(String[][] input, int mode) { - Object[] ob = getListForDisplay(input, getStringListMode(), null); - String[] ss = new String[ob.length]; - System.arraycopy(ob, 0, ss, 0, ob.length); - return ss; - } - - public final Object[] getListForDisplay(Object[][] input, Comparator cmp) { - return getListForDisplay(input, getStringListMode(), cmp); - } - /** - * Utility method forms string list - * according to current list display mode - * - * @param input - array of string arrays - * @return - */ - private final Object[] getListForDisplay(Object[][] input, int mode, Comparator cmp) { - if (input == null || input.length == 0) - return EMPTY_ARRAY; - if (input.length == 1) { - return (input[0] == null) ? - EMPTY_ARRAY : - input[0]; - } - - Object[] s1 = input[0]; - if (s1 == null || - s1.length == 0) - return EMPTY_ARRAY; - - if ((mode & DMODES) == DMODE_EMPTY) { - Arrays.sort(s1, cmp); - for (int i=1; i list = new ArrayList(); CResourceData rcDatas[] = data.getResourceDatas(); for(int i = 0; i < rcDatas.length; i++){ list.add(rcDatas[i]); @@ -261,7 +261,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC CBuildData buildData = data.getBuildData(); list.add(buildData); // TODO add other data types - return (CDataObject[])list.toArray(new CDataObject[list.size()]); + return list.toArray(new CDataObject[list.size()]); } public boolean isStatic() { @@ -526,16 +526,16 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC // return des; // } - public Map getReferenceInfo() { + public Map getReferenceInfo() { try { CConfigurationSpecSettings specs = getSpecSettings(); return specs.getReferenceInfo(); } catch (CoreException e) { } - return new HashMap(0); + return new HashMap(0); } - public void setReferenceInfo(Map refs) { + public void setReferenceInfo(Map refs) { try { CConfigurationSpecSettings specs = getSpecSettings(); specs.setReferenceInfo(refs); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java index 852bfc4e5c0..d8fc2110b2b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.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 @@ -67,7 +67,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ private StorableCdtVariables fMacros; private StorableEnvironment fEnvironment; // private HashMap fRefInfoMap; - private Map fRefMapCache; + private Map fRefMapCache; private CExternalSettingsHolder fExtSettingsProvider = new CExternalSettingsHolder(); private boolean fIsModified; private HashMap fSessionPropertiesMap; @@ -387,12 +387,12 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ fEnvironment = environment; } - public Map getReferenceInfo(){ + public Map getReferenceInfo(){ if(!fCfg.isReadOnly()) return CfgExportSettingContainerFactory.getReferenceMap(fCfg); if(fRefMapCache == null) fRefMapCache = CfgExportSettingContainerFactory.getReferenceMap(fCfg); - return new HashMap(fRefMapCache); + return new HashMap(fRefMapCache); // if(fRefInfoMap == null || fRefInfoMap.size() == 0) // return new HashMap(0); // @@ -420,7 +420,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ // fIsModified = true; // } - public void setReferenceInfo(Map ref){ + public void setReferenceInfo(Map ref){ fRefMapCache = null; CfgExportSettingContainerFactory.setReferenceMap(fCfg, ref); // if(isReadOnly()) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgExportSettingContainerFactory.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgExportSettingContainerFactory.java index fe6d61cac4f..bdcc6a857f7 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgExportSettingContainerFactory.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgExportSettingContainerFactory.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 @@ -114,9 +114,9 @@ public class CfgExportSettingContainerFactory extends return new CContainerRef(FACTORY_ID, createId(projName, cfgId)); } - public static Map getReferenceMap(ICConfigurationDescription cfg){ + public static Map getReferenceMap(ICConfigurationDescription cfg){ CContainerRef[] refs = CExternalSettingsManager.getInstance().getReferences(cfg, FACTORY_ID); - Map map = new HashMap(); + Map map = new HashMap(); for(int i = 0; i < refs.length; i++){ try { String[] r = parseId(refs[i].getContainerId()); @@ -129,24 +129,24 @@ public class CfgExportSettingContainerFactory extends return map; } - public static void setReferenceMap(ICConfigurationDescription cfg, Map map){ - Map cur = getReferenceMap(cfg); - Map newCopy = new HashMap(map); + public static void setReferenceMap(ICConfigurationDescription cfg, Map map){ + Map cur = getReferenceMap(cfg); + Map newCopy = new HashMap(map); - for(Iterator iter = cur.entrySet().iterator(); iter.hasNext();){ - Map.Entry entry = (Map.Entry)iter.next(); + for(Iterator> iter = cur.entrySet().iterator(); iter.hasNext();){ + Map.Entry entry = (Map.Entry)iter.next(); Object projName = entry.getKey(); if(newCopy.containsKey(projName) && entry.getValue().equals(newCopy.get(projName))){ iter.remove(); newCopy.remove(projName); } } - for(Iterator iter = cur.entrySet().iterator(); iter.hasNext();){ - Map.Entry entry = (Map.Entry)iter.next(); + for(Iterator> iter = cur.entrySet().iterator(); iter.hasNext();){ + Map.Entry entry = (Map.Entry)iter.next(); removeReference(cfg, (String)entry.getKey(), (String)entry.getValue()); } - for(Iterator iter = newCopy.entrySet().iterator(); iter.hasNext();){ - Map.Entry entry = (Map.Entry)iter.next(); + for(Iterator> iter = newCopy.entrySet().iterator(); iter.hasNext();){ + Map.Entry entry = (Map.Entry)iter.next(); createReference(cfg, (String)entry.getKey(), (String)entry.getValue()); } } @@ -215,7 +215,7 @@ public class CfgExportSettingContainerFactory extends return new String[0]; int deltaKind = delta.getDeltaKind(); - List cfgIds = new ArrayList(); + List cfgIds = new ArrayList(); switch(deltaKind){ case ICDescriptionDelta.ADDED: case ICDescriptionDelta.REMOVED: @@ -247,9 +247,9 @@ public class CfgExportSettingContainerFactory extends return ids; } - public Collection collectCfgIds(ICDescriptionDelta[] deltas, Collection c){ + public Collection collectCfgIds(ICDescriptionDelta[] deltas, Collection c){ if(c == null) - c = new ArrayList(); + c = new ArrayList(); for(int i = 0; i < deltas.length; i++){ ICDescriptionDelta delta = deltas[i]; int deltaKind = delta.getDeltaKind(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiConfigDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiConfigDescription.java index 5550a0ea893..e30bf0e0e56 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiConfigDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiConfigDescription.java @@ -26,7 +26,6 @@ import org.eclipse.cdt.core.settings.model.ICFileDescription; import org.eclipse.cdt.core.settings.model.ICFolderDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSetting; import org.eclipse.cdt.core.settings.model.ICMultiConfigDescription; -import org.eclipse.cdt.core.settings.model.ICMultiItemsHolder; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICResourceDescription; import org.eclipse.cdt.core.settings.model.ICSettingContainer; @@ -50,9 +49,8 @@ public class MultiConfigDescription extends MultiItemsHolder implements ICConfigurationDescription[] fCfgs = null; - public MultiConfigDescription(ICConfigurationDescription[] des, int mode) { + public MultiConfigDescription(ICConfigurationDescription[] des) { fCfgs = des; - setStringListMode(mode); } /* (non-Javadoc) @@ -116,11 +114,11 @@ public class MultiConfigDescription extends MultiItemsHolder implements return null; } - public String[] getErrorParserIDs() { + public String[][] getErrorParserIDs() { String[][] out = new String[fCfgs.length][]; for (int i=0; i getReferenceInfo() { System.out.println("Bad multi access: MultiConfigDescription.getReferenceInfo()"); - return Collections.EMPTY_MAP; + return Collections.emptyMap(); } /* (non-Javadoc) @@ -268,12 +265,10 @@ public class MultiConfigDescription extends MultiItemsHolder implements return (ICResourceDescription)lst.get(0); if (isForFolder) return new MultiFolderDescription( - (ICFolderDescription[])lst.toArray(new ICFolderDescription[lst.size()]), - getStringListMode()); + (ICFolderDescription[])lst.toArray(new ICFolderDescription[lst.size()])); else return new MultiFileDescription( - (ICFileDescription[])lst.toArray(new ICFileDescription[lst.size()]), - getStringListMode()); + (ICFileDescription[])lst.toArray(new ICFileDescription[lst.size()])); } /* (non-Javadoc) @@ -293,7 +288,7 @@ public class MultiConfigDescription extends MultiItemsHolder implements ICFolderDescription[] rds = new ICFolderDescription[fCfgs.length]; for (int i=0; i refs) throws WriteAccessException { for (int i=0; i comp = CDTListComparator.getInstance(); - private ICLanguageSetting[] lsets = null; - - public MultiFolderDescription(ICFolderDescription[] res, int mode) { - super(res, mode); + public MultiFolderDescription(ICFolderDescription[] res) { + super(res); } /* (non-Javadoc) @@ -70,19 +66,10 @@ public class MultiFolderDescription extends MultiResourceDescription implements return ls0; } - private ICLanguageSetting[] conv2LS(Object[] ob) { - ICLanguageSetting[] se = new ICLanguageSetting[ob.length]; - System.arraycopy(ob, 0, se, 0, ob.length); - return se; - } - /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICFolderDescription#getLanguageSettings() */ - public ICLanguageSetting[] getLanguageSettings() { - if (lsets != null) - return lsets; - + public ICLanguageSetting[][] getLanguageSettingsM(Comparator comp) { ICLanguageSetting[][] ls = new ICLanguageSetting[fRess.length][]; for (int i=0; i list = new ArrayList(fRess.length); - for (int j=0; j= 0) - list.add(ls[j][x]); - } - if (list.size() == 1) - lsets[i] = (ICLanguageSetting)list.get(0); - else if (list.size() > 1) - lsets[i] = new MultiLanguageSetting(list, getConfiguration()); - } - return lsets; + return ls; } /* (non-Javadoc) @@ -137,9 +110,13 @@ public class MultiFolderDescription extends MultiResourceDescription implements */ public boolean isRoot() { for (int i=0; i vars = new ArrayList(collected.length); IEnvironmentVariable var; IEnvironmentContextInfo info = new DefaultEnvironmentContextInfo(des);//getContextInfo(des); for(int i = 0; i < collected.length; i++){ @@ -86,7 +81,7 @@ public class ContributedEnvironment implements IContributedEnvironment{ if(var != null) vars.add(var); } - return (EnvVarDescriptor[])vars.toArray(new EnvVarDescriptor[vars.size()]); + return vars.toArray(new EnvVarDescriptor[vars.size()]); } return new EnvVarDescriptor[0]; } @@ -118,6 +113,21 @@ public class ContributedEnvironment implements IContributedEnvironment{ EnvironmentVariableManager.fUserSupplier); } + public void addVariables(IEnvironmentVariable[] vars, + ICConfigurationDescription des) { + for (IEnvironmentVariable v : vars) + addVariable(v, des); + } + + public IEnvironmentVariable addVariable(IEnvironmentVariable var, + ICConfigurationDescription des) { + return addVariable(var.getName(), + var.getValue(), + var.getOperation(), + var.getDelimiter(), + des); + } + public IEnvironmentVariable removeVariable(String name, ICConfigurationDescription des){ return EnvironmentVariableManager.fUserSupplier.deleteVariable(name, des); } @@ -135,6 +145,6 @@ public class ContributedEnvironment implements IContributedEnvironment{ public void serialize(ICProjectDescription des){ EnvironmentVariableManager.fUserSupplier.storeProjectEnvironment(des, false); } - + } 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 f8f74044c2b..4cf731605bf 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 @@ -632,4 +632,28 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab { protected void setBackgroundText(String s) { background.setText(s == null ? BACKGROUND_TEXT_DEFAULT : s); } + + protected void updateLbs(Label lb1, Label lb2) { + if (page.isMultiCfg()) { + if (lb1 != null) { + lb1.setText(CDTPrefUtil.getDMode()); + lb1.setVisible(true); + } + if (lb2 != null) { + lb2.setText(CDTPrefUtil.getWMode()); + lb2.setVisible(true); + } + } else { + if (lb1 != null) + lb1.setVisible(false); + if (lb2 != null) + lb2.setVisible(false); + } + } + + protected boolean isWModifyMode() { + int wmode = CDTPrefUtil.getInt(CDTPrefUtil.KEY_WMODE); + return (wmode == CDTPrefUtil.WMODE_MODIFY); + } + } 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 305ebd30b27..abb630c4e9b 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 @@ -13,6 +13,7 @@ package org.eclipse.cdt.ui.newui; import java.util.ArrayList; import java.util.Arrays; +import java.util.Comparator; import java.util.LinkedList; import java.util.List; @@ -27,6 +28,8 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.accessibility.AccessibleAdapter; import org.eclipse.swt.accessibility.AccessibleEvent; import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.events.SelectionAdapter; @@ -39,6 +42,7 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.Tree; @@ -47,6 +51,7 @@ import org.eclipse.swt.widgets.TreeItem; import org.eclipse.cdt.core.model.ILanguageDescriptor; import org.eclipse.cdt.core.model.LanguageManager; +import org.eclipse.cdt.core.model.MultiLanguageSetting; import org.eclipse.cdt.core.model.util.CDTListComparator; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICExternalSetting; @@ -54,6 +59,7 @@ import org.eclipse.cdt.core.settings.model.ICFileDescription; import org.eclipse.cdt.core.settings.model.ICFolderDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSetting; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; +import org.eclipse.cdt.core.settings.model.ICMultiFolderDescription; import org.eclipse.cdt.core.settings.model.ICMultiResourceDescription; import org.eclipse.cdt.core.settings.model.ICResourceDescription; import org.eclipse.cdt.core.settings.model.ICSettingBase; @@ -69,6 +75,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { protected Button showBIButton; protected boolean toAllCfgs = false; protected boolean toAllLang = false; + protected Label lb1, lb2; protected ICLanguageSetting lang; protected LinkedList incs; @@ -81,6 +88,8 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { protected final static String[] BUTTSYM = {ADD_STR, EDIT_STR, DEL_STR, UIMessages.getString("AbstractLangsListTab.2")}; //$NON-NLS-1$ + private static final Comparator comp = CDTListComparator.getInstance(); + private final static Image IMG_FS = CPluginImages.get(CPluginImages.IMG_FILESYSTEM); private final static Image IMG_WS = CPluginImages.get(CPluginImages.IMG_WORKSPACE); private final static Image IMG_MK = CPluginImages.get(CPluginImages.IMG_OBJS_MACRO); @@ -88,12 +97,14 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { public void createControls(Composite parent) { super.createControls(parent); - usercomp.setLayout(new GridLayout(1, false)); + usercomp.setLayout(new GridLayout(2, true)); // Create the sash form sashForm = new SashForm(usercomp, SWT.NONE); sashForm.setOrientation(SWT.HORIZONTAL); - sashForm.setLayoutData(new GridData(GridData.FILL_BOTH)); + GridData gd = new GridData(GridData.FILL_BOTH); + gd.horizontalSpan = 2; + sashForm.setLayoutData(gd); GridLayout layout = new GridLayout(); layout.numColumns = 2; @@ -102,7 +113,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { addTree(sashForm).setLayoutData(new GridData(GridData.FILL_VERTICAL)); table = new Table(sashForm, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.FULL_SELECTION); - GridData gd = new GridData(GridData.FILL_BOTH); + gd = new GridData(GridData.FILL_BOTH); gd.widthHint = 255; table.setLayoutData(gd); table.setHeaderVisible(true); @@ -153,12 +164,32 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { } }); setupLabel(usercomp, EMPTY_STR, 1, 0); + + lb1 = new Label(usercomp, SWT.BORDER | SWT.CENTER); + lb1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + lb1.setToolTipText(UIMessages.getString("EnvironmentTab.15")); //$NON-NLS-1$ + lb1.addMouseListener(new MouseAdapter() { + public void mouseDoubleClick(MouseEvent e) { + CDTPrefUtil.spinDMode(); + update(); + }}); + showBIButton = setupCheck(usercomp, UIMessages.getString("AbstractLangsListTab.0"), 1, GridData.FILL_HORIZONTAL); //$NON-NLS-1$ showBIButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { update(); } }); + + lb2 = new Label(usercomp, SWT.BORDER | SWT.CENTER); + lb2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + lb2.setToolTipText(UIMessages.getString("EnvironmentTab.23")); //$NON-NLS-1$ + lb2.addMouseListener(new MouseAdapter() { + public void mouseDoubleClick(MouseEvent e) { + CDTPrefUtil.spinWMode(); + updateLbs(null, lb2); + }}); + additionalTableSet(); initButtons((getKind() == ICSettingEntry.MACRO) ? BUTTSYM : BUTTONS); updateData(getResDesc()); @@ -195,10 +226,10 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { buttonSetEnabled(0, canAdd); // add buttonSetEnabled(1, canEdit); // edit buttonSetEnabled(2, canDelete); // delete - buttonSetEnabled(3, canExport); // export + buttonSetEnabled(3, canExport && !page.isMultiCfg()); // export // there is a separator instead of button #4 - buttonSetEnabled(5, canMoveUp); // up - buttonSetEnabled(6, canMoveDown); // down + buttonSetEnabled(5, canMoveUp && !page.isMultiCfg()); // up + buttonSetEnabled(6, canMoveDown && !page.isMultiCfg()); // down } private Tree addTree(Composite comp) { @@ -260,28 +291,34 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { if (x == -1) x = 0; else x += shift; // used only for UP/DOWN - incs = new LinkedList(); - List lst = getSettingEntriesList(getKind()); - if (lst != null) { - for (ICLanguageSettingEntry ent : lst) { - if (!ent.isBuiltIn()) - incs.add(ent); - } - if (showBIButton.getSelection()) { - ArrayList lstS = new ArrayList(); - for (ICLanguageSettingEntry ent : lst) - if (ent.isBuiltIn()) - lstS.add(ent); - incs.addAll(lstS); - } - } + incs = getIncs(); tv.setInput(incs.toArray(new Object[incs.size()])); if (table.getItemCount() > x) table.select(x); else if (table.getItemCount() > 0) table.select(0); } + + updateLbs(lb1, lb2); updateButtons(); } + protected LinkedList getIncs() { + LinkedList l = new LinkedList(); + List lst = getSettingEntriesList(getKind()); + if (lst != null) { + for (ICLanguageSettingEntry ent : lst) { + if (!ent.isBuiltIn()) + l.add(ent); + } + if (showBIButton.getSelection()) { + for (ICLanguageSettingEntry ent : lst) + if (ent.isBuiltIn()) + l.add(ent); + } + } + return l; + } + + /** * Called when configuration changed * Refreshes languages list and calls table refresh. @@ -336,11 +373,82 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { } } } + + private void performAdd(ICLanguageSettingEntry ent) { + if (ent != null) { + if ((toAllCfgs || toAllLang) && ! (getResDesc() instanceof ICMultiResourceDescription)) { + addToAll(ent); + } else { + if (isWModifyMode() && (lang instanceof MultiLanguageSetting)) { + performMulti(ent, false); + } else { + incs.add(ent); + setSettingEntries(getKind(), incs, toAllLang); + } + } + update(); + } + } + + private void performMulti(ICLanguageSettingEntry ent, boolean delete) { + MultiLanguageSetting ms = (MultiLanguageSetting)lang; + ICLanguageSetting[] ls = (ICLanguageSetting[])ms.getItems(); + ICLanguageSettingEntry[][] es = ms.getSettingEntriesM(getKind()); + for (int i=0; i entries = + new ArrayList(Arrays.asList(es[i])); + for (ICLanguageSettingEntry e : entries) + if (e.getName().equals(ent.getName())) { + entries.remove(e); + break; + } + if (!delete) + entries.add(ent); + ls[i].setSettingEntries(getKind(), entries); + } + } + + private void performEdit(int n) { + if (n == -1) return; + ICLanguageSettingEntry old = (ICLanguageSettingEntry)(table.getItem(n).getData()); + if (old.isReadOnly()) return; + ICLanguageSettingEntry ent = doEdit(old); + if (ent != null) { + if (isWModifyMode() && (lang instanceof MultiLanguageSetting)) { + performMulti(ent, false); + } else { + int toModify = incs.indexOf(old); + incs.remove(toModify); + incs.add(toModify, ent); + setSettingEntries(getKind(), incs, false); + } + update(); + } + } + + private void performDelete(int n) { + if (n == -1) return; + int[] ids = table.getSelectionIndices(); + if (isWModifyMode() && (lang instanceof MultiLanguageSetting)) { + for (int x=ids.length-1; x>=0; x--) { + ICLanguageSettingEntry old = (ICLanguageSettingEntry)(table.getItem(ids[x]).getData()); + performMulti(old, true); + } + } else { + for (int x=ids.length-1; x>=0; x--) { + ICLanguageSettingEntry old = (ICLanguageSettingEntry)(table.getItem(ids[x]).getData()); + if (old.isReadOnly()) continue; + incs.remove(old); + } + setSettingEntries(getKind(), incs, false); + } + update(); + + } /** * Unified buttons handler */ public void buttonPressed(int i) { - ICLanguageSettingEntry ent; ICLanguageSettingEntry old; int n = table.getSelectionIndex(); int ids[] = table.getSelectionIndices(); @@ -349,39 +457,13 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { case 0: // add toAllCfgs = false; toAllLang = false; - ent = doAdd(); - if (ent != null) { - if ((toAllCfgs || toAllLang) && ! (getResDesc() instanceof ICMultiResourceDescription)) { - addToAll(ent); - } else { - incs.add(ent); - setSettingEntries(getKind(), incs, toAllLang); - } - update(); - } + performAdd(doAdd()); break; case 1: // edit - if (n == -1) return; - old = (ICLanguageSettingEntry)(table.getItem(n).getData()); - if (old.isReadOnly()) return; - ent = doEdit(old); - if (ent != null) { - int toModify = incs.indexOf(old); - incs.remove(toModify); - incs.add(toModify, ent); - setSettingEntries(getKind(), incs, false); - update(); - } + performEdit(n); break; case 2: // delete - if (n == -1) return; - for (int x=ids.length-1; x>=0; x--) { - old = (ICLanguageSettingEntry)(table.getItem(ids[x]).getData()); - if (old.isReadOnly()) continue; - incs.remove(old); - } - setSettingEntries(getKind(), incs, false); - update(); + performDelete(n); break; case 3: // toggle export if (n == -1) return; @@ -472,8 +554,13 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { ICLanguageSetting [] sr = getLangSetting(src); ICLanguageSetting [] ds = getLangSetting(dst); if (sr == null || ds == null || sr.length != ds.length) return; - for (int i=0; i list = new ArrayList(ls.length); + for (int j=0; j= 0) + list.add(ls[j][x]); + } + if (list.size() == 1) + lsets[i] = list.get(0); + else if (list.size() > 1) + lsets[i] = new MultiLanguageSetting(list, foDes.getConfiguration()); + } + return lsets; + } + + public boolean canBeVisible() { if (getResDesc() == null) return true; ICLanguageSetting [] ls = getLangSetting(getResDesc()); @@ -570,6 +682,20 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { lang.setSettingEntries(kind, incs); } private List getSettingEntriesList(int kind) { - return lang.getSettingEntriesList(kind); + if (page.isMultiCfg() && lang instanceof MultiLanguageSetting) { + ICLanguageSettingEntry[][] lses = ((MultiLanguageSetting)lang).getSettingEntriesM(kind); + Object[] res = CDTPrefUtil.getListForDisplay(lses, comp); + ICLanguageSettingEntry[] out = new ICLanguageSettingEntry[res.length]; + System.arraycopy(res, 0, out, 0, res.length); + return Arrays.asList(out); + } else + return lang.getSettingEntriesList(kind); } + + private ICLanguageSetting[] conv2LS(Object[] ob) { + ICLanguageSetting[] se = new ICLanguageSetting[ob.length]; + System.arraycopy(ob, 0, se, 0, ob.length); + return se; + } + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java index 49181184003..527f9cb41df 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java @@ -401,9 +401,7 @@ implements cfgIndex = selectionIndex; } } - // TODO: avoid repeated update like for single cfg - cfgChanged(MultiItemsHolder.createCDescription(multiCfgs, - ICMultiItemsHolder.MODE_DEFAULT)); + cfgChanged(MultiItemsHolder.createCDescription(multiCfgs)); return; } else { String id1 = getResDesc() == null ? null : getResDesc().getId(); @@ -1013,7 +1011,9 @@ implements return true; // Projects and folders are always applicable } - // update views (in particular, display resource configurations) + /** + * update views (in particular, display resource configurations) + */ public static void updateViews(IResource res) { if (res == null) return; IWorkbenchPartReference refs[] = CUIPlugin.getActiveWorkbenchWindow().getActivePage().getViewReferences(); @@ -1023,7 +1023,10 @@ implements ((IPropertyChangeListener)part).propertyChange(new PropertyChangeEvent(res, PreferenceConstants.PREF_SHOW_CU_CHILDREN, null, null)); } } - + + /** + * Adjusts form size according to contents dimensions + */ public void resize() { Shell sh = parentComposite.getShell(); Point p0 = sh.getLocation(); @@ -1034,9 +1037,18 @@ implements sh.setSize(p1); } + /** + * Returns Apply button widget + * Allows public access to it. + */ public Button getAButton() { return getApplyButton(); } + + /** + * Returns Default button widget. + * Allows public access to it. + */ public Button getDButton() { return getDefaultsButton(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPrefUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPrefUtil.java index aedfaa7a552..0bec1b4101a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPrefUtil.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPrefUtil.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 @@ -10,13 +10,17 @@ *******************************************************************************/ package org.eclipse.cdt.ui.newui; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Comparator; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.TreeSet; + +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.jface.preference.IPreferenceStore; public class CDTPrefUtil { // boolean keys (KEY_NO-s are to be inverted !) @@ -43,19 +47,20 @@ public class CDTPrefUtil { public static final int DISC_NAMING_DEFAULT = DISC_NAMING_UNIQUE_OR_BOTH; public static final String KEY_DMODE = "properties.multi.displ.mode"; //$NON-NLS-1$ - public static final int DMODE_EMPTY = 1; - public static final int DMODE_CONJUNCTION = 2; - public static final int DMODE_DISJUNCTION = 4; + public static final int DMODE_CONJUNCTION = 1; + public static final int DMODE_DISJUNCTION = 2; public static final String KEY_WMODE = "properties.multi.write.mode"; //$NON-NLS-1$ - public static final int WMODE_MODIFY = 8; - public static final int WMODE_REPLACE = 16; + public static final int WMODE_MODIFY = 4; + public static final int WMODE_REPLACE = 8; public static final String NULL = "NULL"; //$NON-NLS-1$ private static final IPreferenceStore pref = CUIPlugin.getDefault().getPreferenceStore(); private static final String DELIMITER = " "; //$NON-NLS-1$ private static LinkedList preferredTCs = null; + public static final Object[] EMPTY_ARRAY = new Object[0]; + // low-level methods public static boolean getBool(String key) { return pref.getBoolean(key); } public static void setBool(String key, boolean val) { pref.setValue(key, val); } @@ -96,4 +101,134 @@ public class CDTPrefUtil { } setStr(KEY_PREFTC, b.toString().trim()); } + + public static String getDMode() { + String s = null; + switch(CDTPrefUtil.getInt(CDTPrefUtil.KEY_DMODE)) { + case CDTPrefUtil.DMODE_CONJUNCTION: + s = UIMessages.getString("EnvironmentTab.17"); //$NON-NLS-1$ + break; + case CDTPrefUtil.DMODE_DISJUNCTION: + s = UIMessages.getString("EnvironmentTab.18"); //$NON-NLS-1$ + break; + } + return UIMessages.getString("EnvironmentTab.19") + s; //$NON-NLS-1$ + } + + public static String getWMode() { + String s = null; + switch(CDTPrefUtil.getInt(CDTPrefUtil.KEY_WMODE)) { + case CDTPrefUtil.WMODE_MODIFY: + s = UIMessages.getString("EnvironmentTab.20"); //$NON-NLS-1$ + break; + case CDTPrefUtil.WMODE_REPLACE: + s = UIMessages.getString("EnvironmentTab.21"); //$NON-NLS-1$ + break; + } + return UIMessages.getString("EnvironmentTab.22") + s; //$NON-NLS-1$ + } + + public static void spinDMode() { + setInt(KEY_DMODE, + ((getInt(KEY_DMODE) == DMODE_CONJUNCTION) ? + DMODE_DISJUNCTION : + DMODE_CONJUNCTION)); + } + + public static void spinWMode() { + setInt(KEY_WMODE, + ((getInt(KEY_WMODE) == WMODE_MODIFY) ? + WMODE_REPLACE : + WMODE_MODIFY)); + } + + public static final String[] getStrListForDisplay(String[][] input) { + return getStrListForDisplay(input, getInt(KEY_DMODE)); + } + + private static final String[] getStrListForDisplay(String[][] input, int mode) { + Object[] ob = getListForDisplay(input, getInt(KEY_DMODE), null); + String[] ss = new String[ob.length]; + System.arraycopy(ob, 0, ss, 0, ob.length); + return ss; + } + + public static final Object[] getListForDisplay(Object[][] input, Comparator cmp) { + return getListForDisplay(input, getInt(KEY_DMODE), cmp); + } + /** + * Utility method forms string list + * according to current list display mode + * + * @param input - array of string arrays + * @return + */ + private static final Object[] getListForDisplay(Object[][] input, int mode, Comparator cmp) { + if (input == null || input.length == 0) + return EMPTY_ARRAY; + if (input.length == 1) { + return (input[0] == null) ? + EMPTY_ARRAY : + input[0]; + } + + Object[] s1 = input[0]; + if (s1 == null || + s1.length == 0) + return EMPTY_ARRAY; +/* + if (mode == DMODE_EMPTY) { + Arrays.sort(s1, cmp); + for (int i=1; i lst = new ArrayList(); + for (int i=0; i lst = new TreeSet(cmp); // set, to avoid doubles + for (int i=0; i data = new ArrayList(); private Button b1, b2; + private Label lb1, lb2; private ICConfigurationDescription cfgd = null; private StorableEnvironment vars = null; @@ -143,7 +146,7 @@ public class EnvironmentTab extends AbstractCPropertyTab { public void createControls(Composite parent) { super.createControls(parent); - usercomp.setLayout(new GridLayout(1, false)); + usercomp.setLayout(new GridLayout(2, true)); Label l1 = new Label(usercomp, SWT.LEFT); l1.setText(UIMessages.getString("EnvironmentTab.0")); //$NON-NLS-1$ l1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -181,8 +184,10 @@ public class EnvironmentTab extends AbstractCPropertyTab { tc = new TableColumn(table, SWT.LEFT); tc.setText(UIMessages.getString("EnvironmentTab.2")); //$NON-NLS-1$ tc.setWidth(200); - - table.setLayoutData(new GridData(GridData.FILL_BOTH)); + + GridData gd = new GridData(GridData.FILL_BOTH); + gd.horizontalSpan = 2; + table.setLayoutData(gd); b1 = new Button(usercomp, SWT.RADIO); b1.setText(UIMessages.getString("EnvironmentTab.3")); //$NON-NLS-1$ @@ -196,6 +201,15 @@ public class EnvironmentTab extends AbstractCPropertyTab { updateData(); }}); + lb1 = new Label(usercomp, SWT.BORDER | SWT.CENTER); + lb1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + lb1.setToolTipText(UIMessages.getString("EnvironmentTab.15")); //$NON-NLS-1$ + lb1.addMouseListener(new MouseAdapter() { + public void mouseDoubleClick(MouseEvent e) { + CDTPrefUtil.spinDMode(); + updateData(); + }}); + b2 = new Button(usercomp, SWT.RADIO); b2.setText(UIMessages.getString("EnvironmentTab.4")); //$NON-NLS-1$ b2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -207,101 +221,36 @@ public class EnvironmentTab extends AbstractCPropertyTab { vars.setAppendContributedEnvironment(false); updateData(); }}); - + + lb2 = new Label(usercomp, SWT.BORDER | SWT.CENTER); + lb2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + lb2.setToolTipText(UIMessages.getString("EnvironmentTab.23")); //$NON-NLS-1$ + lb2.addMouseListener(new MouseAdapter() { + public void mouseDoubleClick(MouseEvent e) { + CDTPrefUtil.spinWMode(); + updateLbs(null, lb2); + }}); initButtons(new String[] {UIMessages.getString("EnvironmentTab.5"),UIMessages.getString("EnvironmentTab.6"),UIMessages.getString("EnvironmentTab.7"),UIMessages.getString("EnvironmentTab.8"),UIMessages.getString("EnvironmentTab.9")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ } - + public void buttonPressed(int i) { - IEnvironmentVariable var = null; - EnvDialog dlg; - int n = table.getSelectionIndex(); - int[] idx; switch (i) { case 0: - dlg = new EnvDialog(usercomp.getShell(), - var, - UIMessages.getString("EnvironmentTab.10"), //$NON-NLS-1$ - true, - page.isMultiCfg(), - cfgd); - if (dlg.open() == Window.OK) { - if (dlg.t1.trim().length() > 0) { - ICConfigurationDescription[] cfgs; - if (dlg.toAll) - cfgs = page.getCfgsEditable(); - else - cfgs = new ICConfigurationDescription[] {cfgd}; - if (cfgd == null) - vars.createVariable(dlg.t1.trim(), dlg.t2.trim(), - IEnvironmentVariable.ENVVAR_APPEND, SEMI); - else - for (int x=0; x 0) { + ICConfigurationDescription[] cfgs; + if (dlg.toAll) + cfgs = page.getCfgsEditable(); + else + cfgs = new ICConfigurationDescription[] {cfgd}; + if (cfgd == null) + vars.createVariable(dlg.t1.trim(), dlg.t2.trim(), + IEnvironmentVariable.ENVVAR_APPEND, SEMI); + else + for (int x=0; x data = new ArrayList(mapParsers.size()); ArrayList checked = new ArrayList(ss.length); @@ -182,9 +187,13 @@ public class ErrorParsTab extends AbstractCPropertyTab { protected void performApply(ICResourceDescription src, ICResourceDescription dst) { ICConfigurationDescription sd = src.getConfiguration(); ICConfigurationDescription dd = dst.getConfiguration(); - String[] s = (sd instanceof ICMultiConfigDescription) ? - ((ICMultiConfigDescription)sd).getErrorParserIDs() : - sd.getBuildSetting().getErrorParserIDs(); + String[] s = null; + if (sd instanceof ICMultiConfigDescription) { + String[][] ss = ((ICMultiConfigDescription)sd).getErrorParserIDs(); + s = CDTPrefUtil.getStrListForDisplay(ss); + } else { + s = sd.getBuildSetting().getErrorParserIDs(); + } if (dd instanceof ICMultiConfigDescription) ((ICMultiConfigDescription)sd).setErrorParserIDs(s); else diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiCfgContributedEnvironment.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiCfgContributedEnvironment.java index 57dab20b613..5051ad09d0f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiCfgContributedEnvironment.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiCfgContributedEnvironment.java @@ -1,6 +1,14 @@ -/** - * - */ +/******************************************************************************* + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel Corporation - initial API and implementation + * IBM Corporation + *******************************************************************************/ package org.eclipse.cdt.ui.newui; import java.util.Comparator; @@ -10,7 +18,6 @@ import org.eclipse.cdt.core.envvar.IContributedEnvironment; import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICMultiConfigDescription; -import org.eclipse.cdt.core.settings.model.ICMultiItemsHolder; import org.eclipse.cdt.core.settings.model.MultiItemsHolder; /** @@ -21,10 +28,9 @@ public class MultiCfgContributedEnvironment implements IContributedEnvironment { private static final IContributedEnvironment ice = CCorePlugin.getDefault().getBuildEnvironmentManager().getContributedEnvironment(); private boolean isMulti = false; private ICConfigurationDescription[] mono = new ICConfigurationDescription[1]; - private ICConfigurationDescription[] cfs; private static final EnvCmp comparator = new EnvCmp(); - private static class EnvCmp implements Comparator { + private static class EnvCmp implements Comparator { public int compare(Object a0, Object a1) { if (a0 == null || a1 == null) @@ -51,17 +57,31 @@ public class MultiCfgContributedEnvironment implements IContributedEnvironment { public IEnvironmentVariable addVariable(String name, String value, int op, String delimiter, ICConfigurationDescription des) { - cfs = getCfs(des); IEnvironmentVariable v = null; - for (int i=0; i()); initData(); } protected void updateButtons() {} // Do nothing. No buttons to update. 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 f655837e588..61d3b3c8b39 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 @@ -14,7 +14,6 @@ package org.eclipse.cdt.ui.newui; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; -import java.util.LinkedList; import org.eclipse.swt.SWT; import org.eclipse.swt.accessibility.AccessibleAdapter; @@ -74,8 +73,9 @@ public class SymbolTab extends AbstractLangsListTab { int x = table.getSelectionIndex(); if (x == -1) x = 0; +// incs = new LinkedList(lang.getSettingEntriesList(getKind())); + incs = getIncs(); ArrayList lst = new ArrayList(); - incs = new LinkedList(lang.getSettingEntriesList(getKind())); if (incs != null) { Iterator it = incs.iterator(); while (it.hasNext()) { @@ -88,6 +88,7 @@ public class SymbolTab extends AbstractLangsListTab { if (table.getItemCount() > x) table.select(x); else if (table.getItemCount() > 0) table.select(0); } + updateLbs(lb1, lb2); updateButtons(); }