mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
crecoskie July 8, 2005
- applying patch from Jeremiah Lott to extract some functionality into protected methods
This commit is contained in:
parent
4c6445634e
commit
c299e7df97
3 changed files with 97 additions and 46 deletions
|
@ -248,6 +248,18 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
|||
// If the user did not visit this page, then there is nothing to do.
|
||||
if (!displayedConfig) return true;
|
||||
|
||||
if (!applyOptionBlock()) return false;
|
||||
if (!applyDefaultConfiguration()) return false;
|
||||
if (!writeBuildInfo()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply any changes that have been made in the managed build option block
|
||||
* (changes are stored in the managedbuildinfo object).
|
||||
*/
|
||||
protected boolean applyOptionBlock() {
|
||||
IRunnableWithProgress runnable = new IRunnableWithProgress() {
|
||||
public void run(IProgressMonitor monitor) {
|
||||
fOptionBlock.performApply(monitor);
|
||||
|
@ -264,9 +276,23 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
|||
// cancelled
|
||||
return false;
|
||||
}
|
||||
|
||||
// Write out the build model info
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the currently selected configuration the default
|
||||
* (in the managedbuildinfo object).
|
||||
*/
|
||||
protected boolean applyDefaultConfiguration() {
|
||||
ManagedBuildManager.setDefaultConfiguration(getProject(), getSelectedConfiguration());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save any changes applied to the managedbuildinfo object to disk.
|
||||
*/
|
||||
protected boolean writeBuildInfo() {
|
||||
// Write out the build model info
|
||||
ManagedBuildManager.saveBuildInfo(getProject(), false);
|
||||
IManagedBuildInfo bi = ManagedBuildManager.getBuildInfo(getProject());
|
||||
if (bi != null & bi instanceof ManagedBuildInfo) {
|
||||
|
@ -274,7 +300,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.jface.preference.PreferencePage#performDefaults()
|
||||
|
@ -313,16 +339,9 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
|||
configSelector.setItems(getConfigurationNamesAndDescriptions());
|
||||
|
||||
// Make sure the active configuration is selected
|
||||
configSelector.select(0);
|
||||
IConfiguration defaultConfig = info.getDefaultConfiguration();
|
||||
int index;
|
||||
if( (defaultConfig.getDescription() == null) || defaultConfig.getDescription().equals("") ) { //$NON-NLS-1$
|
||||
index = configSelector.indexOf(defaultConfig.getName());
|
||||
} else {
|
||||
index = configSelector.indexOf(defaultConfig.getName() + "( " + defaultConfig.getDescription() + " )" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
configSelector.select(index == -1 ? 0 : index);
|
||||
handleConfigSelection();
|
||||
setSelectedConfiguration(defaultConfig);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -341,9 +360,38 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
|||
return namesAndDescriptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the currently selected configuration and updates the UI to reflect
|
||||
* the current state of that configuration.
|
||||
*/
|
||||
public void setSelectedConfiguration(IConfiguration config) {
|
||||
String nameAndDescription = new String();
|
||||
if ((config.getDescription() == null)
|
||||
|| (config.getDescription().equals(""))) { //$NON-NLS-1$
|
||||
nameAndDescription = config.getName();
|
||||
} else {
|
||||
nameAndDescription = config.getName() + "( " //$NON-NLS-1$
|
||||
+ config.getDescription() + " )"; //$NON-NLS-1$
|
||||
}
|
||||
configSelector.select(configSelector.indexOf(nameAndDescription));
|
||||
handleConfigSelection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the control for selecting a configuration to edit should
|
||||
* be enabled.
|
||||
*/
|
||||
public void enableConfigSelection (boolean enable) {
|
||||
configSelector.setEnabled(enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the control for managing the configurations should be
|
||||
* enabled.
|
||||
*/
|
||||
public void enabledManageConfigs (boolean enable) {
|
||||
manageConfigs.setEnabled(false);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @return
|
||||
|
@ -522,16 +570,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
|||
configSelector.setItems(getConfigurationNamesAndDescriptions());
|
||||
|
||||
IConfiguration tmpSelectedConfiguration = manageDialog.getSelectedConfiguration();
|
||||
String nameAndDescription = new String();
|
||||
if ((tmpSelectedConfiguration.getDescription() == null)
|
||||
|| (tmpSelectedConfiguration.getDescription().equals(""))) { //$NON-NLS-1$
|
||||
nameAndDescription = tmpSelectedConfiguration.getName();
|
||||
} else {
|
||||
nameAndDescription = tmpSelectedConfiguration.getName() + "( " //$NON-NLS-1$
|
||||
+ tmpSelectedConfiguration.getDescription() + " )"; //$NON-NLS-1$
|
||||
}
|
||||
configSelector.select(configSelector.indexOf(nameAndDescription));
|
||||
handleConfigSelection();
|
||||
setSelectedConfiguration(tmpSelectedConfiguration);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -71,8 +71,6 @@ public class ManageConfigDialog extends Dialog {
|
|||
private static final String CONVERSION_TARGET_TIP = TIP + ".conversionTarget"; //$NON-NLS-1$
|
||||
private static final String CONVERT_TIP = TIP + ".convert"; //$NON-NLS-1$
|
||||
|
||||
private static final String ID_SEPARATOR = "."; //$NON-NLS-1$
|
||||
|
||||
private static final String EMPTY_STRING = new String();
|
||||
|
||||
// The list of configurations to delete
|
||||
|
@ -465,29 +463,8 @@ public class ManageConfigDialog extends Dialog {
|
|||
IConfiguration parentConfig = dialog.getParentConfiguration();
|
||||
|
||||
if (parentConfig != null) {
|
||||
int id = ManagedBuildManager.getRandomNumber();
|
||||
|
||||
// Create ID for the new component based on the parent ID and random component
|
||||
String newId = parentConfig.getId();
|
||||
int index = newId.lastIndexOf(ID_SEPARATOR);
|
||||
if (index > 0) {
|
||||
String lastComponent = newId.substring(index + 1, newId.length());
|
||||
if (Character.isDigit(lastComponent.charAt(0))) {
|
||||
// Strip the last component
|
||||
newId = newId.substring(0, index);
|
||||
}
|
||||
}
|
||||
newId += ID_SEPARATOR + id;
|
||||
IConfiguration newConfig;
|
||||
if (parentConfig.isExtensionElement()) {
|
||||
newConfig = info.getManagedProject().createConfiguration(parentConfig, newId);
|
||||
} else {
|
||||
newConfig = info.getManagedProject().createConfigurationClone(parentConfig, newId);
|
||||
}
|
||||
|
||||
newConfig.setName(newConfigName);
|
||||
newConfig.setDescription(newConfigDescription);
|
||||
newConfig.setArtifactName(info.getManagedProject().getDefaultArtifactName());
|
||||
IConfiguration newConfig = dialog.newConfiguration(info);
|
||||
|
||||
// Add this new configuration to the existing list.
|
||||
String nameAndDescription = new String();
|
||||
|
|
|
@ -10,8 +10,11 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.ui.properties;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IProjectType;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import org.eclipse.cdt.internal.ui.dialogs.StatusDialog;
|
||||
|
@ -51,6 +54,8 @@ public class NewConfigurationDialog extends StatusDialog {
|
|||
private static final String INVALID = ERROR + ".invalidName"; //$NON-NLS-1$
|
||||
private static final String DESCRIPTION = LABEL + ".description"; //$NON-NLS-1$
|
||||
|
||||
private static final String ID_SEPARATOR = "."; //$NON-NLS-1$
|
||||
|
||||
// Widgets
|
||||
private Button btnClone;
|
||||
private Button btnCopy;
|
||||
|
@ -522,5 +527,35 @@ public class NewConfigurationDialog extends StatusDialog {
|
|||
return newDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new configuration, using the values currently set in
|
||||
* the dialog.
|
||||
*/
|
||||
public IConfiguration newConfiguration(IManagedBuildInfo info) {
|
||||
int id = ManagedBuildManager.getRandomNumber();
|
||||
|
||||
// Create ID for the new component based on the parent ID and random component
|
||||
String newId = parentConfig.getId();
|
||||
int index = newId.lastIndexOf(ID_SEPARATOR);
|
||||
if (index > 0) {
|
||||
String lastComponent = newId.substring(index + 1, newId.length());
|
||||
if (Character.isDigit(lastComponent.charAt(0))) {
|
||||
// Strip the last component
|
||||
newId = newId.substring(0, index);
|
||||
}
|
||||
}
|
||||
newId += ID_SEPARATOR + id;
|
||||
IConfiguration newConfig;
|
||||
if (parentConfig.isExtensionElement()) {
|
||||
newConfig = info.getManagedProject().createConfiguration(parentConfig, newId);
|
||||
} else {
|
||||
newConfig = info.getManagedProject().createConfigurationClone(parentConfig, newId);
|
||||
}
|
||||
|
||||
newConfig.setName(newName);
|
||||
newConfig.setDescription(newDescription);
|
||||
newConfig.setArtifactName(info.getManagedProject().getDefaultArtifactName());
|
||||
return newConfig;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue