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

Empty entry in combo of build properties, bug 248341.

This commit is contained in:
Markus Schorn 2008-10-01 15:22:35 +00:00
parent 41f790c534
commit deb0082dc5
2 changed files with 115 additions and 37 deletions

View file

@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Intel Corporation - initial API and implementation * Intel Corporation - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Andrew Gvozdev
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.newui; package org.eclipse.cdt.ui.newui;
@ -115,7 +116,7 @@ implements
{ {
private static ICResourceDescription resd = null; private static ICResourceDescription resd = null;
private static ICConfigurationDescription[] cfgDescs = null; private static ICConfigurationDescription[] cfgDescs = null;
private static int cfgIndex = -1; private static ICConfigurationDescription lastSelectedCfg = null;
private static ICConfigurationDescription[] multiCfgs = null; // selected multi cfg private static ICConfigurationDescription[] multiCfgs = null; // selected multi cfg
// tabs // tabs
private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.cPropertyTab"; //$NON-NLS-1$ private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.cPropertyTab"; //$NON-NLS-1$
@ -198,7 +199,8 @@ implements
public AbstractPage() { public AbstractPage() {
if (CDTPropertyManager.getPagesCount() == 0) { if (CDTPropertyManager.getPagesCount() == 0) {
cfgDescs = null; cfgDescs = null;
cfgIndex = -1; lastSelectedCfg = null;
multiCfgs = null;
} }
} }
@ -383,39 +385,103 @@ implements
if (configSelector.getItemCount() == 0) return; if (configSelector.getItemCount() == 0) return;
int selectionIndex = configSelector.getSelectionIndex(); int selectionIndex = configSelector.getSelectionIndex();
if (selectionIndex == -1) return; if (selectionIndex == -1) return;
if (cfgDescs == null || cfgDescs.length == 0) return;
// Check if the user has selected the "all / multiple" configuration // Check if the user has selected the "all / multiple" configuration
if (selectionIndex >= cfgDescs.length) { if (selectionIndex >= cfgDescs.length) {
if ((selectionIndex - cfgDescs.length) == 0) { // all if (selectionIndex == cfgDescs.length) { // all
multiCfgs = cfgDescs; multiCfgs = cfgDescs;
cfgIndex = selectionIndex;
} else { // multiple } else { // multiple
if (cfgIndex != selectionIndex) { // to avoid re-request on page change // Check previous state of variables figuring out if need to pop up selection dialog
// areCfgsStillThere() covers deletions by a user in Manage Configurations dialog
boolean enterMultiCfgsDialog = (multiCfgs == null)
|| (multiCfgs == cfgDescs) || !areCfgsStillThere(multiCfgs);
if (enterMultiCfgsDialog) {
ICConfigurationDescription[] mcfgs = ConfigMultiSelectionDialog.select(cfgDescs); ICConfigurationDescription[] mcfgs = ConfigMultiSelectionDialog.select(cfgDescs);
if (mcfgs == null || mcfgs.length == 0) { if (mcfgs == null || mcfgs.length == 0) {
// return back to previous selection // return back to previous selection
if (cfgIndex > configSelector.getItemCount()) { int cfgIndex = -1;
cfgIndex = 0; if (multiCfgs == cfgDescs) { // return to choice "All"
configSelector.select(0); cfgIndex = cfgDescs.length;
cfgChanged(cfgDescs[0]);
} else { } else {
configSelector.select(cfgIndex); cfgIndex = getCfgIndex(lastSelectedCfg);
} }
configSelector.select(cfgIndex);
return; return;
} }
multiCfgs = mcfgs; multiCfgs = mcfgs;
cfgIndex = selectionIndex;
} }
} }
cfgChanged(MultiItemsHolder.createCDescription(multiCfgs)); lastSelectedCfg = null;
cfgChanged(MultiItemsHolder.createCDescription(multiCfgs));
return; return;
} }
multiCfgs = null;
String id1 = getResDesc() == null ? null : getResDesc().getId(); String id1 = getResDesc() == null ? null : getResDesc().getId();
cfgIndex = selectionIndex; lastSelectedCfg = cfgDescs[selectionIndex];
ICConfigurationDescription newConfig = cfgDescs[selectionIndex]; String id2 = lastSelectedCfg.getId();
String id2 = newConfig.getId(); if (id2 != null && !id2.equals(id1)) {
if (id2 != null && !id2.equals(id1)) cfgChanged(lastSelectedCfg);
cfgChanged(newConfig); }
}
/**
* Find index of configuration description in the internal array of
* configuration descriptions.
*
* @param cfgd
* @return index of found configuration description or index of active
* configuration.
*/
private static int getCfgIndex(ICConfigurationDescription cfgd) {
int index = 0;
for (int i = 0; i < cfgDescs.length; ++i) {
if (cfgd != null) {
if (cfgd.getId().equals(cfgDescs[i].getId())) {
return i;
}
} else if (cfgDescs[i].isActive()) {
index = i;
}
}
return index;
}
/**
* Find index of active configuration description in the internal array of
* configuration descriptions.
*
* @return index of active configuration description.
*/
private static int getActiveCfgIndex() {
return getCfgIndex(null);
}
/**
* Check if all configuration descriptions are present in the internal array of
* configuration descriptions.
* @param cfgs
* @return true if all present, false otherwise
*/
private static boolean areCfgsStillThere(ICConfigurationDescription[] cfgs) {
if (cfgs==null || cfgDescs==null) return false;
for (ICConfigurationDescription multiCfg : cfgs) {
boolean foundOne = false;
for (ICConfigurationDescription cfgDesc : cfgDescs) {
if (multiCfg.getId().equals(cfgDesc.getId())) {
foundOne = true;
break;
}
}
if (!foundOne) {
return false;
}
}
return true;
} }
@Override @Override
@ -585,7 +651,7 @@ implements
return false; return false;
} catch (InterruptedException e) {} } catch (InterruptedException e) {}
return true; return true;
} }
private void populateConfigurations() { private void populateConfigurations() {
IProject prj = getProject(); IProject prj = getProject();
@ -600,36 +666,49 @@ implements
Arrays.sort(cfgDescs, CDTListComparator.getInstance()); Arrays.sort(cfgDescs, CDTListComparator.getInstance());
} else { } else {
if (cfgDescs.length == 0) return;
// just register in CDTPropertyManager; // just register in CDTPropertyManager;
CDTPropertyManager.getProjectDescription(this, prj); CDTPropertyManager.getProjectDescription(this, prj);
} }
// Do nothing if widget not created yet. // Do nothing if widget not created yet.
if (configSelector == null) { if (configSelector == null) {
if (cfgDescs != null && cfgDescs.length > 0) { lastSelectedCfg = cfgDescs[getActiveCfgIndex()];
for (int i = 0; i < cfgDescs.length; ++i) { cfgChanged(lastSelectedCfg);
if (cfgIndex == -1 && cfgDescs[i].isActive())
cfgIndex = i;
}
if (cfgIndex < 0) {
cfgIndex = 0;
}
cfgChanged(cfgDescs[cfgIndex]);
}
return; return;
} }
// Clear and replace the contents of the selector widget // Clear and replace the contents of the selector widget
configSelector.removeAll(); configSelector.removeAll();
for (int i = 0; i < cfgDescs.length; ++i) { for (int i = 0; i < cfgDescs.length; ++i) {
configSelector.add(cfgDescs[i].getName()); String name = cfgDescs[i].getName();
if (cfgIndex == -1 && cfgDescs[i].isActive()) if (cfgDescs[i].isActive()) {
cfgIndex = i; name = name + " " + UIMessages.getString("AbstractPage.16"); //$NON-NLS-1$ //$NON-NLS-2$
}
configSelector.add(name);
} }
if (cfgDescs.length > 1) // "All cfgs" - shown if at least 2 cfgs available
int cfgIndex = -1;
// "All cfgs" - shown if at least 2 cfgs available
if (cfgDescs.length > 1) {
configSelector.add(UIMessages.getString("AbstractPage.4")); //$NON-NLS-1$ configSelector.add(UIMessages.getString("AbstractPage.4")); //$NON-NLS-1$
if (cfgDescs.length > 2)// "Multi cfgs" - shown if at least 3 cfgs available if (multiCfgs == cfgDescs) {
cfgIndex = cfgDescs.length;
}
}
// "Multi cfgs" - shown if at least 3 cfgs available
if (cfgDescs.length > 2) {
configSelector.add(UIMessages.getString("AbstractPage.5")); //$NON-NLS-1$ configSelector.add(UIMessages.getString("AbstractPage.5")); //$NON-NLS-1$
if (multiCfgs != null && multiCfgs != cfgDescs) {
cfgIndex = cfgDescs.length + 1;
}
}
if (cfgIndex<0) {
cfgIndex = getActiveCfgIndex();
}
configSelector.select(cfgIndex); configSelector.select(cfgIndex);
handleConfigSelection(); handleConfigSelection();
} }
@ -757,12 +836,10 @@ implements
if (resd == null) { if (resd == null) {
if (cfgDescs == null) { if (cfgDescs == null) {
populateConfigurations(); populateConfigurations();
if (cfgDescs == null || cfgDescs.length == 0) return null;
} }
if (cfgDescs.length == 0) { if (lastSelectedCfg!=null) {
return null; resd = getResDesc(lastSelectedCfg);
} }
resd = getResDesc(cfgDescs[cfgIndex]);
} }
return resd; return resd;
} }

View file

@ -341,6 +341,7 @@ AbstractPage.10=Cannot create resource configuration for
AbstractPage.13=Cannot load AbstractPage.13=Cannot load
AbstractPage.14=Cannot create page: AbstractPage.14=Cannot create page:
AbstractPage.15=element not initialized. AbstractPage.15=element not initialized.
AbstractPage.16=[ Active ]
AbstractPage.2=This project is not a CDT project AbstractPage.2=This project is not a CDT project
AbstractPage.3=Error while accessing new configuration. <Apply> cannot work. Use <OK>. AbstractPage.3=Error while accessing new configuration. <Apply> cannot work. Use <OK>.
AbstractPage.4=[ All configurations ] AbstractPage.4=[ All configurations ]