mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 17:55:39 +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 the user did not visit this page, then there is nothing to do.
|
||||||
if (!displayedConfig) return true;
|
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() {
|
IRunnableWithProgress runnable = new IRunnableWithProgress() {
|
||||||
public void run(IProgressMonitor monitor) {
|
public void run(IProgressMonitor monitor) {
|
||||||
fOptionBlock.performApply(monitor);
|
fOptionBlock.performApply(monitor);
|
||||||
|
@ -264,9 +276,23 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
||||||
// cancelled
|
// cancelled
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
// Write out the build model info
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make the currently selected configuration the default
|
||||||
|
* (in the managedbuildinfo object).
|
||||||
|
*/
|
||||||
|
protected boolean applyDefaultConfiguration() {
|
||||||
ManagedBuildManager.setDefaultConfiguration(getProject(), getSelectedConfiguration());
|
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);
|
ManagedBuildManager.saveBuildInfo(getProject(), false);
|
||||||
IManagedBuildInfo bi = ManagedBuildManager.getBuildInfo(getProject());
|
IManagedBuildInfo bi = ManagedBuildManager.getBuildInfo(getProject());
|
||||||
if (bi != null & bi instanceof ManagedBuildInfo) {
|
if (bi != null & bi instanceof ManagedBuildInfo) {
|
||||||
|
@ -274,7 +300,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.eclipse.jface.preference.PreferencePage#performDefaults()
|
* @see org.eclipse.jface.preference.PreferencePage#performDefaults()
|
||||||
|
@ -313,16 +339,9 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
||||||
configSelector.setItems(getConfigurationNamesAndDescriptions());
|
configSelector.setItems(getConfigurationNamesAndDescriptions());
|
||||||
|
|
||||||
// Make sure the active configuration is selected
|
// Make sure the active configuration is selected
|
||||||
|
configSelector.select(0);
|
||||||
IConfiguration defaultConfig = info.getDefaultConfiguration();
|
IConfiguration defaultConfig = info.getDefaultConfiguration();
|
||||||
int index;
|
setSelectedConfiguration(defaultConfig);
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -341,9 +360,38 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
||||||
return namesAndDescriptions;
|
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) {
|
public void enableConfigSelection (boolean enable) {
|
||||||
configSelector.setEnabled(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)
|
/* (non-Javadoc)
|
||||||
* @return
|
* @return
|
||||||
|
@ -522,16 +570,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
||||||
configSelector.setItems(getConfigurationNamesAndDescriptions());
|
configSelector.setItems(getConfigurationNamesAndDescriptions());
|
||||||
|
|
||||||
IConfiguration tmpSelectedConfiguration = manageDialog.getSelectedConfiguration();
|
IConfiguration tmpSelectedConfiguration = manageDialog.getSelectedConfiguration();
|
||||||
String nameAndDescription = new String();
|
setSelectedConfiguration(tmpSelectedConfiguration);
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
return;
|
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 CONVERSION_TARGET_TIP = TIP + ".conversionTarget"; //$NON-NLS-1$
|
||||||
private static final String CONVERT_TIP = TIP + ".convert"; //$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();
|
private static final String EMPTY_STRING = new String();
|
||||||
|
|
||||||
// The list of configurations to delete
|
// The list of configurations to delete
|
||||||
|
@ -465,29 +463,8 @@ public class ManageConfigDialog extends Dialog {
|
||||||
IConfiguration parentConfig = dialog.getParentConfiguration();
|
IConfiguration parentConfig = dialog.getParentConfiguration();
|
||||||
|
|
||||||
if (parentConfig != null) {
|
if (parentConfig != null) {
|
||||||
int id = ManagedBuildManager.getRandomNumber();
|
|
||||||
|
|
||||||
// Create ID for the new component based on the parent ID and random component
|
IConfiguration newConfig = dialog.newConfiguration(info);
|
||||||
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());
|
|
||||||
|
|
||||||
// Add this new configuration to the existing list.
|
// Add this new configuration to the existing list.
|
||||||
String nameAndDescription = new String();
|
String nameAndDescription = new String();
|
||||||
|
|
|
@ -10,8 +10,11 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.managedbuilder.ui.properties;
|
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.IProjectType;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import org.eclipse.cdt.internal.ui.dialogs.StatusDialog;
|
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 INVALID = ERROR + ".invalidName"; //$NON-NLS-1$
|
||||||
private static final String DESCRIPTION = LABEL + ".description"; //$NON-NLS-1$
|
private static final String DESCRIPTION = LABEL + ".description"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String ID_SEPARATOR = "."; //$NON-NLS-1$
|
||||||
|
|
||||||
// Widgets
|
// Widgets
|
||||||
private Button btnClone;
|
private Button btnClone;
|
||||||
private Button btnCopy;
|
private Button btnCopy;
|
||||||
|
@ -522,5 +527,35 @@ public class NewConfigurationDialog extends StatusDialog {
|
||||||
return newDescription;
|
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