1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-14 03:35:37 +02:00

bug 288032: reformatting only

This commit is contained in:
Andrew Gvozdev 2009-08-29 17:29:47 +00:00
parent b37f1f3d9b
commit 0843b02a8f

View file

@ -67,10 +67,6 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
@Deprecated @Deprecated
protected static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$ protected static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
private static final String SC_GROUP_LABEL = "ScannerConfigOptionsDialog.scGroup.label"; //$NON-NLS-1$
private static final String SC_ENABLED_BUTTON = "ScannerConfigOptionsDialog.scGroup.enabled.button"; //$NON-NLS-1$
private static final String SC_PROBLEM_REPORTING_ENABLED_BUTTON = "ScannerConfigOptionsDialog.scGroup.problemReporting.enabled.button"; //$NON-NLS-1$
private static final String SC_SELECTED_PROFILE_COMBO = "ScannerConfigOptionsDialog.scGroup.selectedProfile.combo"; //$NON-NLS-1$
private static final String NAMESPACE = "org.eclipse.cdt.make.ui"; //$NON-NLS-1$ private static final String NAMESPACE = "org.eclipse.cdt.make.ui"; //$NON-NLS-1$
private static final String POINT = "DiscoveryProfilePage"; //$NON-NLS-1$ private static final String POINT = "DiscoveryProfilePage"; //$NON-NLS-1$
private static final String PROFILE_PAGE = "profilePage"; //$NON-NLS-1$ private static final String PROFILE_PAGE = "profilePage"; //$NON-NLS-1$
@ -98,8 +94,13 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
protected SashForm sashForm; protected SashForm sashForm;
private DiscoveryPageWrapper wrapper = null; private DiscoveryPageWrapper wrapper = null;
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) /*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
* .Composite)
*/ */
public void createControls(Composite parent) { public void createControls(Composite parent) {
super.createControls(parent); super.createControls(parent);
@ -107,7 +108,8 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
usercomp.setLayout(new GridLayout(1, false)); usercomp.setLayout(new GridLayout(1, false));
if (page.isForProject() || page.isForPrefs()) { if (page.isForProject() || page.isForPrefs()) {
Group scopeGroup = setupGroup(usercomp, Messages.getString("DiscoveryTab.0"), 1, GridData.FILL_HORIZONTAL); //$NON-NLS-1$ Group scopeGroup = setupGroup(usercomp, Messages.getString("DiscoveryTab.0"),
1, GridData.FILL_HORIZONTAL); //$NON-NLS-1$
scopeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); scopeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
scopeComboBox = new Combo(scopeGroup, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER); scopeComboBox = new Combo(scopeGroup, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
scopeComboBox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); scopeComboBox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@ -115,7 +117,8 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
scopeComboBox.add(Messages.getString("DiscoveryTab.2")); //$NON-NLS-1$ scopeComboBox.add(Messages.getString("DiscoveryTab.2")); //$NON-NLS-1$
scopeComboBox.addSelectionListener(new SelectionAdapter() { scopeComboBox.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
if (cbi == null) return; if (cbi == null)
return;
cbi.setPerRcTypeDiscovery(scopeComboBox.getSelectionIndex() == 0); cbi.setPerRcTypeDiscovery(scopeComboBox.getSelectionIndex() == 0);
updateData(); updateData();
} }
@ -134,14 +137,15 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
fTableDefinition = new Label(comp, SWT.LEFT); fTableDefinition = new Label(comp, SWT.LEFT);
fTableDefinition.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fTableDefinition.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
resTable = new Table(comp, SWT.SINGLE|SWT.H_SCROLL|SWT.V_SCROLL|SWT.BORDER); resTable = new Table(comp, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
GridData gd = new GridData(GridData.FILL_BOTH); GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 150; gd.widthHint = 150;
resTable.setLayoutData(gd); resTable.setLayoutData(gd);
resTable.addSelectionListener(new SelectionAdapter() { resTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
handleToolSelected(); handleToolSelected();
}}); }
});
initializeProfilePageMap(); initializeProfilePageMap();
Composite c = new Composite(sashForm, 0); Composite c = new Composite(sashForm, 0);
@ -160,9 +164,11 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
} }
private void createScannerConfigControls(Composite parent) { private void createScannerConfigControls(Composite parent) {
scGroup = setupGroup(parent, UIMessages.getString(SC_GROUP_LABEL), 2, GridData.FILL_HORIZONTAL); scGroup = setupGroup(parent, UIMessages.getString("ScannerConfigOptionsDialog.scGroup.label"),
2, GridData.FILL_HORIZONTAL);
scEnabledButton = setupCheck(scGroup, UIMessages.getString(SC_ENABLED_BUTTON), 2, GridData.FILL_HORIZONTAL); scEnabledButton = setupCheck(scGroup, UIMessages.getString("ScannerConfigOptionsDialog.scGroup.enabled.button"),
2, GridData.FILL_HORIZONTAL);
scEnabledButton.addSelectionListener(new SelectionAdapter() { scEnabledButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
buildInfo.setAutoDiscoveryEnabled(scEnabledButton.getSelection()); buildInfo.setAutoDiscoveryEnabled(scEnabledButton.getSelection());
@ -171,7 +177,8 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
handleDiscoveryProfileChanged(); handleDiscoveryProfileChanged();
} }
}); });
scProblemReportingEnabledButton = setupCheck(scGroup, UIMessages.getString(SC_PROBLEM_REPORTING_ENABLED_BUTTON), 2, GridData.FILL_HORIZONTAL); scProblemReportingEnabledButton = setupCheck(scGroup, UIMessages.getString("ScannerConfigOptionsDialog.scGroup.problemReporting.enabled.button"),
2, GridData.FILL_HORIZONTAL);
scProblemReportingEnabledButton.addSelectionListener(new SelectionAdapter() { scProblemReportingEnabledButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
buildInfo.setProblemReportingEnabled(scProblemReportingEnabledButton.getSelection()); buildInfo.setProblemReportingEnabled(scProblemReportingEnabledButton.getSelection());
@ -179,7 +186,8 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
}); });
// Add profile combo box // Add profile combo box
setupLabel(scGroup,UIMessages.getString(SC_SELECTED_PROFILE_COMBO), 1, GridData.BEGINNING); setupLabel(scGroup, UIMessages.getString("ScannerConfigOptionsDialog.scGroup.selectedProfile.combo"),
1, GridData.BEGINNING);
profileComboBox = new Combo(scGroup, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER); profileComboBox = new Combo(scGroup, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
profileComboBox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); profileComboBox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
profileComboBox.addSelectionListener(new SelectionAdapter() { profileComboBox.addSelectionListener(new SelectionAdapter() {
@ -208,9 +216,10 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
configPath = rcfg.getPath(); configPath = rcfg.getPath();
IConfiguration cfg = getCfg(rcfg.getConfiguration()); IConfiguration cfg = getCfg(rcfg.getConfiguration());
cbi = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(cfg); cbi = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(cfg);
if(!page.isForPrefs() && baseInfoMap == null){ if (!page.isForPrefs() && baseInfoMap == null) {
try { try {
IScannerConfigBuilderInfo2Set baseCbi = ScannerConfigProfileManager.createScannerConfigBuildInfo2Set(cfg.getOwner().getProject()); IProject project = cfg.getOwner().getProject();
IScannerConfigBuilderInfo2Set baseCbi = ScannerConfigProfileManager.createScannerConfigBuildInfo2Set(project);
baseInfoMap = baseCbi.getInfoMap(); baseInfoMap = baseCbi.getInfoMap();
} catch (CoreException e) { } catch (CoreException e) {
} }
@ -222,7 +231,7 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
private void updateData() { private void updateData() {
int selScope = 0; int selScope = 0;
String lblText = "Tools:"; String lblText = "Tools:";
if(!cbi.isPerRcTypeDiscovery()) { if (!cbi.isPerRcTypeDiscovery()) {
selScope = 1; selScope = 1;
lblText = "Configuration:"; lblText = "Configuration:";
} }
@ -230,7 +239,6 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
scopeComboBox.select(selScope); scopeComboBox.select(selScope);
fTableDefinition.setText(lblText); fTableDefinition.setText(lblText);
Map<CfgInfoContext, IScannerConfigBuilderInfo2> m = cbi.getInfoMap(); Map<CfgInfoContext, IScannerConfigBuilderInfo2> m = cbi.getInfoMap();
int pos = resTable.getSelectionIndex(); int pos = resTable.getSelectionIndex();
resTable.removeAll(); resTable.removeAll();
@ -240,15 +248,18 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
if (rci == null) { // per configuration if (rci == null) { // per configuration
s = ic.getConfiguration().getName(); s = ic.getConfiguration().getName();
} else { // per resource } else { // per resource
if ( ! configPath.equals(rci.getPath())) continue; if (!configPath.equals(rci.getPath()))
continue;
IInputType typ = ic.getInputType(); IInputType typ = ic.getInputType();
if (typ != null) s = typ.getName(); if (typ != null)
s = typ.getName();
if (s == null) { if (s == null) {
ITool tool = ic.getTool(); ITool tool = ic.getTool();
if (tool != null) if (tool != null)
s = tool.getName(); s = tool.getName();
} }
if (s == null) s = Messages.getString("DiscoveryTab.3"); //$NON-NLS-1$ if (s == null)
s = Messages.getString("DiscoveryTab.3"); //$NON-NLS-1$
} }
IScannerConfigBuilderInfo2 bi2 = m.get(ic); IScannerConfigBuilderInfo2 bi2 = m.get(ic);
TableItem ti = new TableItem(resTable, SWT.NONE); TableItem ti = new TableItem(resTable, SWT.NONE);
@ -272,25 +283,25 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
resTable.setEnabled(errMsg == null); resTable.setEnabled(errMsg == null);
if (errMsg != null) { if (errMsg != null) {
String[] ss = errMsg.split("\n"); //$NON-NLS-1$ String[] ss = errMsg.split("\n"); //$NON-NLS-1$
for (int i=0; i<ss.length; i++) for (int i = 0; i < ss.length; i++)
new TableItem(resTable, SWT.NONE).setText(ss[i]); new TableItem(resTable, SWT.NONE).setText(ss[i]);
} }
} }
private String getProfileName(String id) { private String getProfileName(String id) {
int x = id.lastIndexOf("."); //$NON-NLS-1$ int x = id.lastIndexOf("."); //$NON-NLS-1$
return (x == -1) ? id : id.substring(x+1); return (x == -1) ? id : id.substring(x + 1);
} }
private void handleToolSelected() { private void handleToolSelected() {
if (resTable.getSelectionCount() == 0) return; if (resTable.getSelectionCount() == 0)
return;
performOK(false); performOK(false);
TableItem ti = resTable.getSelection()[0]; TableItem ti = resTable.getSelection()[0];
buildInfo = (IScannerConfigBuilderInfo2)ti.getData("info"); //$NON-NLS-1$ buildInfo = (IScannerConfigBuilderInfo2) ti.getData("info"); //$NON-NLS-1$
iContext = (CfgInfoContext)ti.getData("cont"); //$NON-NLS-1$ iContext = (CfgInfoContext) ti.getData("cont"); //$NON-NLS-1$
scEnabledButton.setSelection(buildInfo.isAutoDiscoveryEnabled()); scEnabledButton.setSelection(buildInfo.isAutoDiscoveryEnabled());
scProblemReportingEnabledButton.setSelection(buildInfo.isProblemReportingEnabled()); scProblemReportingEnabledButton.setSelection(buildInfo.isProblemReportingEnabled());
@ -300,7 +311,7 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
visibleProfilesList = new ArrayList<String>(profilesList.size()); visibleProfilesList = new ArrayList<String>(profilesList.size());
if (realPages != null && realPages.length > 0) { if (realPages != null && realPages.length > 0) {
for (int i=0; i<realPages.length; i++) { for (int i = 0; i < realPages.length; i++) {
if (realPages[i] != null) { if (realPages[i] != null) {
realPages[i].setVisible(false); realPages[i].setVisible(false);
realPages[i].dispose(); realPages[i].dispose();
@ -316,30 +327,30 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
String savedId = buildInfo.getSelectedProfileId(); String savedId = buildInfo.getSelectedProfileId();
ITool[] tools = null; ITool[] tools = null;
boolean needPerRcProfile = cbi.isPerRcTypeDiscovery(); boolean needPerRcProfile = cbi.isPerRcTypeDiscovery();
if(!page.isForPrefs()) { if (!page.isForPrefs()) {
Tool tool = (Tool)iContext.getTool(); Tool tool = (Tool) iContext.getTool();
if(null == tool) { if (null == tool) {
IConfiguration conf = iContext.getConfiguration(); IConfiguration conf = iContext.getConfiguration();
if(null != conf) { if (null != conf) {
tools = conf.getToolChain().getTools(); tools = conf.getToolChain().getTools();
} }
if(null == tools) if (null == tools)
return; return;
} } else {
else
tools = new ITool[] { tool }; tools = new ITool[] { tool };
} }
}
for (String profileId : profilesList) { for (String profileId : profilesList) {
if(tools != null) { if (tools != null) {
boolean ok = false; boolean ok = false;
for(int i = 0; i < tools.length; ++i) { for (int i = 0; i < tools.length; ++i) {
IInputType[] inputTypes = ((Tool)tools[i]).getAllInputTypes(); IInputType[] inputTypes = ((Tool) tools[i]).getAllInputTypes();
if(null != inputTypes) { if (null != inputTypes) {
for(IInputType it : inputTypes) { for (IInputType it : inputTypes) {
String[] requiedProfiles = getDiscoveryProfileIds(tools[i], it); String[] requiedProfiles = getDiscoveryProfileIds(tools[i], it);
if(null != requiedProfiles) { if (null != requiedProfiles) {
for(String requiredProfile : requiedProfiles) { for (String requiredProfile : requiedProfiles) {
if(profileId.equals(requiredProfile)) { if (profileId.equals(requiredProfile)) {
ok = true; ok = true;
break; break;
} }
@ -347,7 +358,7 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
} }
} }
} }
if(ok) if (ok)
break; break;
} }
if (!ok) if (!ok)
@ -376,7 +387,7 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
} }
} }
} }
counter ++; counter++;
} }
profileComboBox.setItems(normalize(labels, profiles, counter)); profileComboBox.setItems(normalize(labels, profiles, counter));
@ -388,12 +399,13 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
} }
private String[] getDiscoveryProfileIds(ITool iTool, IInputType it) { private String[] getDiscoveryProfileIds(ITool iTool, IInputType it) {
String attribute = ((InputType)it).getDiscoveryProfileIdAttribute(); String attribute = ((InputType) it).getDiscoveryProfileIdAttribute();
if(null == attribute) if (null == attribute)
return new String[0]; return new String[0];
// FIXME: temporary; we should add new method to IInputType instead of that // FIXME: temporary; we should add new method to IInputType instead of
// that
String[] profileIds = attribute.split("\\|"); String[] profileIds = attribute.split("\\|");
for(int i = 0; i < profileIds.length; ++i) for (int i = 0; i < profileIds.length; ++i)
profileIds[i] = profileIds[i].trim(); profileIds[i] = profileIds[i].trim();
return profileIds; return profileIds;
} }
@ -403,21 +415,21 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
String[] tmp = new String[counter]; String[] tmp = new String[counter];
// Always show either Name + ID, or ID only // Always show either Name + ID, or ID only
// These cases do not require checking for doubles. // These cases do not require checking for doubles.
if (mode == CDTPrefUtil.DISC_NAMING_ALWAYS_BOTH || if (mode == CDTPrefUtil.DISC_NAMING_ALWAYS_BOTH || mode == CDTPrefUtil.DISC_NAMING_ALWAYS_IDS) {
mode == CDTPrefUtil.DISC_NAMING_ALWAYS_IDS){ for (int i = 0; i < counter; i++) {
for (int i=0; i<counter; i++) tmp[i] = (mode == CDTPrefUtil.DISC_NAMING_ALWAYS_IDS)
tmp[i] = (mode == CDTPrefUtil.DISC_NAMING_ALWAYS_IDS) ? ? ids[i]
ids[i] : : combine(labels[i], ids[i]);
combine(labels[i], ids[i]); }
return tmp; return tmp;
} }
// For not-unique names only, either display ID or name + ID // For not-unique names only, either display ID or name + ID
boolean doubles = false; boolean doubles = false;
outer:
// quick check for at least one double // quick check for at least one double
for (int i=0; i<counter; i++) { outer:
for (int j=0; j<counter; j++) { for (int i = 0; i < counter; i++) {
for (int j = 0; j < counter; j++) {
// sic! i < j, to avoid repeated comparison // sic! i < j, to avoid repeated comparison
if (i < j && labels[i].equals(labels[j])) { if (i < j && labels[i].equals(labels[j])) {
doubles = true; doubles = true;
@ -426,12 +438,12 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
} }
} }
if (!doubles) { // all names are unique. if (!doubles) { // all names are unique.
for (int i=0; i<counter; i++) for (int i = 0; i < counter; i++)
tmp[i] = labels[i]; tmp[i] = labels[i];
} else { } else {
for (int i=0; i<counter; i++) { for (int i = 0; i < counter; i++) {
doubles = false; doubles = false;
for (int j=0; j<counter; j++) { for (int j = 0; j < counter; j++) {
if (i != j && labels[i].equals(labels[j])) { if (i != j && labels[i].equals(labels[j])) {
doubles = true; doubles = true;
break; break;
@ -440,7 +452,8 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
if (doubles) { if (doubles) {
if (mode == CDTPrefUtil.DISC_NAMING_UNIQUE_OR_IDS) if (mode == CDTPrefUtil.DISC_NAMING_UNIQUE_OR_IDS)
tmp[i] = ids[i]; tmp[i] = ids[i];
else // replace with Name + Id else
// replace with Name + Id
tmp[i] = combine(labels[i], ids[i]); tmp[i] = combine(labels[i], ids[i]);
} else { // this name is unique - no changes ! } else { // this name is unique - no changes !
tmp[i] = labels[i]; tmp[i] = labels[i];
@ -451,15 +464,17 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
} }
private String combine(String s1, String s2) { private String combine(String s1, String s2) {
if (s1.equals(s2)) return s1; if (s1.equals(s2))
else return s1 + " (" + s2 + ")"; //$NON-NLS-1$ //$NON-NLS-2$ return s1;
else
return s1 + " (" + s2 + ")"; //$NON-NLS-1$ //$NON-NLS-2$
} }
private void handleDiscoveryProfileChanged() { private void handleDiscoveryProfileChanged() {
int pos = profileComboBox.getSelectionIndex(); int pos = profileComboBox.getSelectionIndex();
for (int i=0; i<realPages.length; i++) for (int i = 0; i < realPages.length; i++)
if (realPages[i] != null) if (realPages[i] != null)
realPages[i].setVisible(i==pos); realPages[i].setVisible(i == pos);
} }
/** /**
@ -467,9 +482,9 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
*/ */
private void initializeProfilePageMap() { private void initializeProfilePageMap() {
pagesList = new ArrayList<DiscoveryProfilePageConfiguration>(5); pagesList = new ArrayList<DiscoveryProfilePageConfiguration>(5);
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint( IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(NAMESPACE, POINT);
NAMESPACE, POINT); if (point == null)
if (point == null) return; return;
IConfigurationElement[] infos = point.getConfigurationElements(); IConfigurationElement[] infos = point.getConfigurationElements();
for (int i = 0; i < infos.length; i++) { for (int i = 0; i < infos.length; i++) {
if (infos[i].getName().equals(PROFILE_PAGE)) { if (infos[i].getName().equals(PROFILE_PAGE)) {
@ -487,28 +502,32 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
IConfigurationElement fElement; IConfigurationElement fElement;
private String profId, name; private String profId, name;
protected DiscoveryProfilePageConfiguration(IConfigurationElement element) { protected DiscoveryProfilePageConfiguration(
IConfigurationElement element) {
fElement = element; fElement = element;
profId = fElement.getAttribute(PROFILE_ID); profId = fElement.getAttribute(PROFILE_ID);
name = fElement.getAttribute(PROFILE_NAME); name = fElement.getAttribute(PROFILE_NAME);
} }
protected String getName() { return name; }
private AbstractDiscoveryPage getPage() protected String getName() {
{ return name;
}
private AbstractDiscoveryPage getPage() {
try { try {
return (AbstractDiscoveryPage) fElement.createExecutableExtension("class"); //$NON-NLS-1$ return (AbstractDiscoveryPage) fElement.createExecutableExtension("class"); //$NON-NLS-1$
} catch (CoreException e) { return null; } } catch (CoreException e) {
return null;
}
} }
} }
public void performApply(ICResourceDescription src,ICResourceDescription dst) { public void performApply(ICResourceDescription src,
ICResourceDescription dst) {
if (page.isMultiCfg()) if (page.isMultiCfg())
return; return;
ICfgScannerConfigBuilderInfo2Set cbi1 = ICfgScannerConfigBuilderInfo2Set cbi1 = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(getCfg(src.getConfiguration()));
CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(getCfg(src.getConfiguration())); ICfgScannerConfigBuilderInfo2Set cbi2 = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(getCfg(dst.getConfiguration()));
ICfgScannerConfigBuilderInfo2Set cbi2 =
CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(getCfg(dst.getConfiguration()));
cbi2.setPerRcTypeDiscovery(cbi1.isPerRcTypeDiscovery()); cbi2.setPerRcTypeDiscovery(cbi1.isPerRcTypeDiscovery());
Map<CfgInfoContext, IScannerConfigBuilderInfo2> m1 = cbi1.getInfoMap(); Map<CfgInfoContext, IScannerConfigBuilderInfo2> m1 = cbi1.getInfoMap();
@ -539,7 +558,7 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
if (buildInfo == null) if (buildInfo == null)
return; return;
String savedId = buildInfo.getSelectedProfileId(); String savedId = buildInfo.getSelectedProfileId();
for (int i=0; i<realPages.length; i++) { for (int i = 0; i < realPages.length; i++) {
if (realPages != null && realPages[i] != null) { if (realPages != null && realPages[i] != null) {
String s = visibleProfilesList.get(i); String s = visibleProfilesList.get(i);
buildInfo.setSelectedProfileId(s); buildInfo.setSelectedProfileId(s);
@ -549,48 +568,48 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
} }
buildInfo.setSelectedProfileId(savedId); buildInfo.setSelectedProfileId(savedId);
handleDiscoveryProfileChanged(); handleDiscoveryProfileChanged();
if(ok) if (ok)
clearChangedDiscoveredInfos(); clearChangedDiscoveredInfos();
} }
private void clearChangedDiscoveredInfos(){ private void clearChangedDiscoveredInfos() {
List<CfgInfoContext> changedContexts = checkChanges(); List<CfgInfoContext> changedContexts = checkChanges();
IProject project = getProject(); IProject project = getProject();
for(int i = 0; i < changedContexts.size(); i++){ for (int i = 0; i < changedContexts.size(); i++) {
CfgInfoContext c = changedContexts.get(i); CfgInfoContext c = changedContexts.get(i);
CfgDiscoveredPathManager.getInstance().removeDiscoveredInfo(project, c); CfgDiscoveredPathManager.getInstance().removeDiscoveredInfo(project, c);
// MakeCorePlugin.getDefault().getDiscoveryManager().removeDiscoveredInfo(c.getProject(), c); // MakeCorePlugin.getDefault().getDiscoveryManager().removeDiscoveredInfo(c.getProject(), c);
} }
} }
private List<CfgInfoContext> checkChanges(){ private List<CfgInfoContext> checkChanges() {
if(cbi == null || baseInfoMap == null) if (cbi == null || baseInfoMap == null)
return new ArrayList<CfgInfoContext>(0); return new ArrayList<CfgInfoContext>(0);
Map<CfgInfoContext, IScannerConfigBuilderInfo2> cfgInfoMap = cbi.getInfoMap(); Map<CfgInfoContext, IScannerConfigBuilderInfo2> cfgInfoMap = cbi.getInfoMap();
HashMap<InfoContext, Object> baseCopy = new HashMap<InfoContext, Object>(baseInfoMap); HashMap<InfoContext, Object> baseCopy = new HashMap<InfoContext, Object>(baseInfoMap);
List<CfgInfoContext> list = new ArrayList<CfgInfoContext>(); List<CfgInfoContext> list = new ArrayList<CfgInfoContext>();
for(Map.Entry<CfgInfoContext, IScannerConfigBuilderInfo2> entry : cfgInfoMap.entrySet()){ for (Map.Entry<CfgInfoContext, IScannerConfigBuilderInfo2> entry : cfgInfoMap.entrySet()) {
CfgInfoContext cic = entry.getKey(); CfgInfoContext cic = entry.getKey();
InfoContext c = cic.toInfoContext(); InfoContext c = cic.toInfoContext();
if(c == null) if (c == null)
continue; continue;
IScannerConfigBuilderInfo2 changed = entry.getValue(); IScannerConfigBuilderInfo2 changed = entry.getValue();
IScannerConfigBuilderInfo2 old = (IScannerConfigBuilderInfo2)baseCopy.remove(c); IScannerConfigBuilderInfo2 old = (IScannerConfigBuilderInfo2) baseCopy.remove(c);
if(old == null){ if (old == null) {
list.add(cic); list.add(cic);
} else if(!settingsEqual(changed, old)){ } else if (!settingsEqual(changed, old)) {
list.add(cic); list.add(cic);
} }
} }
if(baseCopy.size() != 0){ if (baseCopy.size() != 0) {
IConfiguration cfg = cbi.getConfiguration(); IConfiguration cfg = cbi.getConfiguration();
for(InfoContext c : baseCopy.keySet()){ for (InfoContext c : baseCopy.keySet()) {
CfgInfoContext cic = CfgInfoContext.fromInfoContext(cfg, c); CfgInfoContext cic = CfgInfoContext.fromInfoContext(cfg, c);
if(cic != null) if (cic != null)
list.add(cic); list.add(cic);
} }
} }
@ -598,8 +617,9 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
return list; return list;
} }
private boolean settingsEqual(IScannerConfigBuilderInfo2 info1, IScannerConfigBuilderInfo2 info2){ private boolean settingsEqual(IScannerConfigBuilderInfo2 info1,
if(!CDataUtil.objectsEqual(info1.getSelectedProfileId(), info2.getSelectedProfileId())) IScannerConfigBuilderInfo2 info2) {
if (!CDataUtil.objectsEqual(info1.getSelectedProfileId(), info2.getSelectedProfileId()))
return false; return false;
if (!CDataUtil.objectsEqual(info1.getBuildOutputFilePath(), info2.getBuildOutputFilePath())) if (!CDataUtil.objectsEqual(info1.getBuildOutputFilePath(), info2.getBuildOutputFilePath()))
return false; return false;
@ -607,10 +627,10 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
return false; return false;
if (!CDataUtil.objectsEqual(info1.getSelectedProfileId(), info2.getSelectedProfileId())) if (!CDataUtil.objectsEqual(info1.getSelectedProfileId(), info2.getSelectedProfileId()))
return false; return false;
if (info1.isAutoDiscoveryEnabled() != info2.isAutoDiscoveryEnabled() || if (info1.isAutoDiscoveryEnabled() != info2.isAutoDiscoveryEnabled()
info1.isBuildOutputFileActionEnabled() != info2.isBuildOutputFileActionEnabled() || || info1.isBuildOutputFileActionEnabled() != info2.isBuildOutputFileActionEnabled()
info1.isBuildOutputParserEnabled() != info2.isBuildOutputParserEnabled() || || info1.isBuildOutputParserEnabled() != info2.isBuildOutputParserEnabled()
info1.isProblemReportingEnabled() != info2.isProblemReportingEnabled()) || info1.isProblemReportingEnabled() != info2.isProblemReportingEnabled())
return false; return false;
if (!listEqual(info1.getProfileIdList(), info2.getProfileIdList())) if (!listEqual(info1.getProfileIdList(), info2.getProfileIdList()))
return false; return false;
@ -620,15 +640,20 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
} }
private boolean listEqual(List<String> l1, List<String> l2) { private boolean listEqual(List<String> l1, List<String> l2) {
if (l1 == null && l2 == null) return true; if (l1 == null && l2 == null)
if (l1 == null || l2 == null) return false; return true;
if (l1.size() != l2.size()) return false; if (l1 == null || l2 == null)
return false;
if (l1.size() != l2.size())
return false;
// both lists have items in the same order ? // both lists have items in the same order ?
// since it's most probable, try it first. // since it's most probable, try it first.
if (l1.equals(l2)) return true; if (l1.equals(l2))
return true;
// order may differ... // order may differ...
for (String s : l1) for (String s : l1)
if (!l2.contains(s)) return false; if (!l2.contains(s))
return false;
return true; return true;
} }
@ -642,18 +667,29 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
return true; return true;
// Hide this page for folders and files // Hide this page for folders and files
// if Discovery scope is "per configuration", not "per resource" // if Discovery scope is "per configuration", not "per resource"
ICfgScannerConfigBuilderInfo2Set _cbi = IConfiguration cfg = getCfg(page.getResDesc().getConfiguration());
CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(getCfg(page.getResDesc().getConfiguration())); ICfgScannerConfigBuilderInfo2Set _cbi = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(cfg);
return _cbi.isPerRcTypeDiscovery(); return _cbi.isPerRcTypeDiscovery();
} }
/** /**
* IBuildInfoContainer methods - called from dynamic pages * IBuildInfoContainer methods - called from dynamic pages
*/ */
public IScannerConfigBuilderInfo2 getBuildInfo() { return buildInfo; } public IScannerConfigBuilderInfo2 getBuildInfo() {
public CfgInfoContext getContext() { return iContext; } return buildInfo;
public IProject getProject() { return page.getProject(); } }
public ICConfigurationDescription getConfiguration() { return getResDesc().getConfiguration(); }
public CfgInfoContext getContext() {
return iContext;
}
public IProject getProject() {
return page.getProject();
}
public ICConfigurationDescription getConfiguration() {
return getResDesc().getConfiguration();
}
protected void performDefaults() { protected void performDefaults() {
if (page.isMultiCfg()) if (page.isMultiCfg())
@ -662,9 +698,13 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
for (CfgInfoContext cic : cbi.getInfoMap().keySet()) { for (CfgInfoContext cic : cbi.getInfoMap().keySet()) {
try { try {
cbi.applyInfo(cic, null); cbi.applyInfo(cic, null);
} catch (CoreException e) {} } catch (CoreException e) {
}
} }
updateData(); updateData();
} }
protected void updateButtons() {} // Do nothing. No buttons to update.
protected void updateButtons() {
// Do nothing. No buttons to update.
}
} }