Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.ui/src')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java497
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ErrorParserBlock.java80
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuildOptionBlock.java271
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedMakeStartup.java52
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedProjectOptionBlock.java27
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties63
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ToolsSettingsBlock.java639
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/UpdateManagedProjectAction.java580
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java19
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java270
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java880
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildSettingsPage.java56
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java389
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolsSettingsStore.java197
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ManageConfigDialog.java252
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ManagedBuilderPropertyPage.java174
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java30
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ResourceBuildPropertyPage.java487
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java35
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListLabelProvider.java7
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java107
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ConfigurationContentProvider.java9
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java20
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java93
24 files changed, 3010 insertions, 2224 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java
new file mode 100644
index 00000000000..c56976a4295
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java
@@ -0,0 +1,497 @@
+/**********************************************************************
+ * Copyright (c) 2002,2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * QNX Software Systems - Move to Make plugin
+ * Intel Corp - Use in Managed Make system
+***********************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.ui;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Label;
+
+public class BuildSettingsBlock extends AbstractCOptionPage {
+
+ /*
+ * String constants
+ */
+ private static final String PREFIX = "BuildSettingsBlock"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String SETTINGS_LABEL = LABEL + ".Settings"; //$NON-NLS-1$
+ private static final String GROUP = LABEL + ".makecmdgroup"; //$NON-NLS-1$
+ private static final String DEF_BTN = LABEL + ".makecmddef"; //$NON-NLS-1$
+ private static final String OUTPUT_GROUP = LABEL + ".output.group"; //$NON-NLS-1$
+ private static final String OUTPUT_EXT = LABEL + ".output.extension"; //$NON-NLS-1$
+ private static final String OUTPUT_NAME = LABEL + ".output.name"; //$NON-NLS-1$
+
+ private static final String EMPTY_STRING = new String();
+
+ /*
+ * Dialog widgets
+ */
+ protected Text buildArtifactExt;
+ protected Text buildArtifactName;
+ protected Button makeCommandDefault;
+ protected Text makeCommandEntry;
+
+ /*
+ * Bookeeping variables
+ */
+ private BuildPropertyPage parent;
+ // The name of the build artifact
+ private String artifactExt;
+ private String artifactName;
+ // The make command associated with the target
+ private String makeCommand;
+ // State of the check box on exit
+ private boolean useDefaultMake;
+ // Has the page been changed?
+ private boolean dirty = false;
+
+ private ModifyListener widgetModified = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ setDirty(true);
+ }
+ };
+
+
+ /*
+ * Constructor
+ */
+ public BuildSettingsBlock(BuildPropertyPage parent)
+ {
+ super(ManagedBuilderUIMessages.getResourceString(SETTINGS_LABEL));
+ super.setContainer(parent);
+ this.parent = parent;
+ }
+
+ public void createControl(Composite parent) {
+ Composite comp = new Composite(parent, SWT.NULL);
+ comp.setFont(parent.getFont());
+ comp.setLayout(new GridLayout(1, true));
+ comp.setLayoutData(new GridData(GridData.FILL_BOTH));
+ setControl(comp);
+
+ // Create a group for the build output
+ createBuildArtifactGroup(comp);
+
+ // Create the make command group area
+ createMakeCommandGroup(comp);
+ }
+
+ /* (non-Javadoc)
+ * Creates the group that contains the build artifact name controls.
+ */
+ private void createBuildArtifactGroup(Composite parent) {
+ final Group outputGroup = new Group(parent, SWT.NONE);
+ outputGroup.setFont(parent.getFont());
+ outputGroup.setText(ManagedBuilderUIMessages.getResourceString(OUTPUT_GROUP));
+ outputGroup.setLayout(new GridLayout(3, false));
+ outputGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // Three labels
+ final Label nameLabel = new Label(outputGroup, SWT.LEFT);
+ nameLabel.setFont(outputGroup.getFont());
+ nameLabel.setText(ManagedBuilderUIMessages.getResourceString(OUTPUT_NAME));
+ nameLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ final Label placeHolder = new Label(outputGroup, SWT.CENTER);
+ placeHolder.setText(new String());
+ placeHolder.setLayoutData(new GridData());
+
+ final Label extLabel = new Label(outputGroup, SWT.LEFT);
+ extLabel.setFont(outputGroup.getFont());
+ extLabel.setText(ManagedBuilderUIMessages.getResourceString(OUTPUT_EXT));
+ extLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // Now we need two text widgets separated by a label
+ buildArtifactName = new Text(outputGroup, SWT.SINGLE | SWT.BORDER);
+ buildArtifactName.setFont(outputGroup.getFont());
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+ buildArtifactName.setLayoutData(data);
+ buildArtifactName.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent event) {
+ buildArtifactName = null;
+ }
+ });
+ buildArtifactName.getAccessible().addAccessibleListener(new AccessibleAdapter(){
+ public void getName(AccessibleEvent e) {
+ e.result = ManagedBuilderUIMessages.getResourceString(OUTPUT_NAME);
+ }
+ });
+ buildArtifactName.addModifyListener(widgetModified);
+
+ final Label dotLabel = new Label(outputGroup, SWT.CENTER);
+ dotLabel.setFont(outputGroup.getFont());
+ dotLabel.setText(new String(".")); //$NON-NLS-1$
+ dotLabel.setLayoutData(new GridData());
+
+ buildArtifactExt = new Text(outputGroup, SWT.SINGLE | SWT.BORDER);
+ buildArtifactExt.setFont(outputGroup.getFont());
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = (IDialogConstants.ENTRY_FIELD_WIDTH / 2);
+ buildArtifactExt.setLayoutData(data);
+ buildArtifactExt.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ buildArtifactExt = null;
+ }
+ });
+ buildArtifactExt.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+ public void getName(AccessibleEvent e) {
+ e.result = ManagedBuilderUIMessages.getResourceString(OUTPUT_EXT);
+ }
+ });
+ buildArtifactExt.addModifyListener(widgetModified);
+ }
+
+ /* (non-Javadoc)
+ * Creates the group control for the make command
+ * @param parent
+ */
+ private void createMakeCommandGroup(Composite parent) {
+ final Group makeCommandGroup = new Group(parent, SWT.NONE);
+ makeCommandGroup.setFont(parent.getFont());
+ makeCommandGroup.setText(ManagedBuilderUIMessages.getResourceString(GROUP));
+ makeCommandGroup.setLayout(new GridLayout(1, true));
+ makeCommandGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ makeCommandDefault = new Button(makeCommandGroup, SWT.CHECK | SWT.LEFT);
+ makeCommandDefault.setFont(makeCommandGroup.getFont());
+ makeCommandDefault.setText(ManagedBuilderUIMessages.getResourceString(DEF_BTN));
+ makeCommandDefault.setBackground(makeCommandGroup.getBackground());
+ makeCommandDefault.setForeground(makeCommandGroup.getForeground());
+ makeCommandDefault.addSelectionListener(new SelectionAdapter () {
+ public void widgetSelected(SelectionEvent e) {
+ handleUseDefaultPressed();
+ setDirty(true);
+ }
+ });
+ makeCommandDefault.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent event) {
+ makeCommandDefault = null;
+ }
+ });
+
+ makeCommandEntry = new Text(makeCommandGroup, SWT.SINGLE | SWT.BORDER);
+ makeCommandEntry.setFont(makeCommandGroup.getFont());
+ makeCommandEntry.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ makeCommandEntry.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent event) {
+ makeCommandEntry = null;
+ }
+ });
+ makeCommandEntry.addModifyListener(widgetModified);
+ }
+
+ protected void initializeValues() {
+ setValues();
+ }
+
+ public void updateValues() {
+ setValues();
+ useDefaultMake = !parent.getSelectedConfiguration().hasOverriddenBuildCommand();
+ makeCommandDefault.setSelection(useDefaultMake);
+ makeCommandEntry.setEditable(!makeCommandDefault.getSelection());
+ }
+
+ protected void setValues() {
+ artifactName = parent.getSelectedConfiguration().getArtifactName();
+ buildArtifactName.setText(artifactName);
+ artifactExt = parent.getSelectedConfiguration().getArtifactExtension();
+ buildArtifactExt.setText(artifactExt);
+ makeCommand = parent.getSelectedConfiguration().getBuildCommand();
+ String makeArgs = parent.getSelectedConfiguration().getBuildArguments();
+ if (makeArgs != null) {
+ makeCommand += " " + makeArgs; //$NON-NLS-1$
+ }
+ makeCommandEntry.setText(makeCommand);
+
+ setDirty(false);
+ }
+
+ public void removeValues(String id) {
+ // Nothing to do...
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
+ */
+ public void performDefaults() {
+ IConfiguration config = parent.getSelectedConfiguration();
+ config.setArtifactName(config.getManagedProject().getDefaultArtifactName());
+ config.setArtifactExtension(null);
+ IBuilder builder = config.getToolChain().getBuilder();
+ if (!builder.isExtensionElement()) {
+ config.getToolChain().removeLocalBuilder();
+ }
+ setValues();
+ makeCommandDefault.setSelection(true);
+ makeCommandEntry.setEditable(false);
+
+ setDirty(false);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(IProgressMonitor)
+ */
+ public void performApply(IProgressMonitor monitor) throws CoreException {
+ useDefaultMake = makeCommandDefault.getSelection();
+ makeCommand = makeCommandEntry.getText().trim();
+ artifactName = buildArtifactName.getText().trim();
+ artifactExt = buildArtifactExt.getText().trim();
+
+ IConfiguration selectedConfiguration = parent.getSelectedConfiguration();
+ IBuilder builder = selectedConfiguration.getToolChain().getBuilder();
+ boolean setBuilderValues = false;
+
+ // Set the build output name
+ if (!selectedConfiguration.getArtifactName().equals(artifactName)) {
+ setBuilderValues = true;
+ }
+ // Set the build output extension
+ if (!selectedConfiguration.getArtifactExtension().equals(artifactExt)) {
+ setBuilderValues = true;
+ }
+ // Set the new make command
+ String makeCommandOnly = null;
+ String makeArguments = null;
+ if (useDefaultMake) {
+ if (!builder.isExtensionElement()) {
+ setBuilderValues = true;
+ }
+ } else {
+ // Parse for command and arguments
+ String rawCommand = makeCommand;
+ makeCommandOnly = parseMakeCommand(rawCommand);
+ if (!selectedConfiguration.getBuildCommand().equals(makeCommandOnly)) {
+ setBuilderValues = true;
+ }
+ makeArguments = parseMakeArgs(rawCommand);
+ if (!selectedConfiguration.getBuildArguments().equals(makeArguments)) {
+ setBuilderValues = true;
+ }
+ }
+
+ if (setBuilderValues) {
+ // If the configuration does not already have a "local" builder, we
+ // need to create it.
+ if (builder.isExtensionElement()) {
+ IToolChain tc = selectedConfiguration.getToolChain();
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId = builder.getId() + "." + nnn; //$NON-NLS-1$
+ String name = builder.getName() + "." + selectedConfiguration.getName(); //$NON-NLS-1$
+ tc.createBuilder(builder, subId, name, false);
+ }
+
+ // Set the builder values
+ selectedConfiguration.setArtifactName(artifactName);
+ selectedConfiguration.setArtifactExtension(artifactExt);
+ selectedConfiguration.setBuildCommand(makeCommandOnly);
+ selectedConfiguration.setBuildArguments(makeArguments);
+ }
+
+ setDirty(false);
+ }
+
+ /* (non-Javadoc)
+ * @param rawCommand
+ * @return
+ */
+ private String parseMakeArgs(String rawCommand) {
+ StringBuffer result = new StringBuffer();
+
+ // Parse out the command
+ String actualCommand = parseMakeCommand(rawCommand);
+
+ // The flags and targets are anything not in the command
+ String arguments = rawCommand.substring(actualCommand.length());
+
+ // If there aren't any, we can stop
+ if (arguments.length() == 0) {
+ return result.toString().trim();
+ }
+
+ String[] tokens = arguments.trim().split("\\s"); //$NON-NLS-1$
+ /*
+ * Cases to consider
+ * --<flag> Sensible, modern single flag. Add to result and continue.
+ * -<flags> Flags in single token, add to result and stop
+ * -<flag_with_arg> ARG Flag with argument. Add next token if valid arg.
+ * -<mixed_flags> ARG Mix of flags, one takes arg. Add next token if valid arg.
+ * -<flag_with_arg>ARG Corrupt case where next token should be arg but isn't
+ * -<flags> [target].. Flags with no args, another token, add flags and stop.
+ */
+ Pattern flagPattern = Pattern.compile("C|f|I|j|l|O|W"); //$NON-NLS-1$
+ // Look for a '-' followed by 1 or more flags with no args and exactly 1 that expects args
+ Pattern mixedFlagWithArg = Pattern.compile("-[^CfIjloW]*[CfIjloW]{1}.+"); //$NON-NLS-1$
+ for (int i = 0; i < tokens.length; ++i) {
+ String currentToken = tokens[i];
+ if (currentToken.startsWith("--")) { //$NON-NLS-1$
+ result.append(currentToken);
+ result.append(" "); //$NON-NLS-1$
+ } else if (currentToken.startsWith("-")) { //$NON-NLS-1$
+ // Is there another token
+ if (i + 1 >= tokens.length) {
+ //We are done
+ result.append(currentToken);
+ } else {
+ String nextToken = tokens[i + 1];
+ // Are we expecting arguments
+ Matcher flagMatcher = flagPattern.matcher(currentToken);
+ if (!flagMatcher.find()) {
+ // Evalutate whether the next token should be added normally
+ result.append(currentToken);
+ result.append(" "); //$NON-NLS-1$
+ } else {
+ // Look for the case where there is no space between flag and arg
+ if (mixedFlagWithArg.matcher(currentToken).matches()) {
+ // Add this single token and keep going
+ result.append(currentToken);
+ result.append(" "); //$NON-NLS-1$
+ } else {
+ // Add this token and the next one right now
+ result.append(currentToken);
+ result.append(" "); //$NON-NLS-1$
+ result.append(nextToken);
+ result.append(" "); //$NON-NLS-1$
+ // Skip the next token the next time through, though
+ ++i;
+ }
+ }
+ }
+ }
+ }
+
+ return result.toString().trim();
+ }
+
+ /* (non-Javadoc)
+ *
+ * @param string
+ * @return
+ */
+ private String parseMakeCommand(String rawCommand) {
+ StringBuffer command = new StringBuffer();
+ boolean hasSpace = false;
+
+ // Try to separate out the command from the arguments
+ String[] result = rawCommand.split("\\s"); //$NON-NLS-1$
+
+ /*
+ * Here are the cases to consider:
+ * cmd First segment is last segment, assume is command
+ * cmd [flags] First segment is the command
+ * path/cmd [flags] Same as above
+ * path with space/make [flags] Must append each segment up-to flags as command
+ */
+ for (int i = 0; i < result.length; ++i) {
+ // Get the segment
+ String cmdSegment = result[i];
+ // If there is not another segment, we found the end
+ if (i + 1 >= result.length) {
+ command.append(cmdSegment);
+ } else {
+ // See if the next segment is the start of the flags
+ String nextSegment = result[i + 1];
+ if (nextSegment.startsWith("-")) { //$NON-NLS-1$
+ // we have found the end of the command
+ command.append(cmdSegment);
+ break;
+ } else {
+ command.append(cmdSegment);
+ // Add the whitespace back
+ command.append(" "); //$NON-NLS-1$
+ hasSpace = true;
+ }
+ }
+ }
+
+// if (hasSpace == true) {
+// return "\"" + command.toString().trim() + "\"";
+// } else {
+ return command.toString().trim();
+// }
+ }
+
+ public IPreferenceStore getPreferenceStore() {
+ return null;
+ }
+ /* (non-Javadoc)
+ * Initialize the "Use default command" field
+ */
+ public void setVisible(boolean visible) {
+ if (visible) {
+ useDefaultMake = !parent.getSelectedConfiguration().hasOverriddenBuildCommand();
+ makeCommandDefault.setSelection(useDefaultMake);
+ makeCommandEntry.setEditable(!makeCommandDefault.getSelection());
+ }
+ super.setVisible(visible);
+ }
+
+ /* (non-Javadoc)
+ * Event handler for the use default check box in the make command group
+ */
+ protected void handleUseDefaultPressed() {
+ // If the state of the button is unchecked, then we want to enable the edit widget
+ boolean checked = makeCommandDefault.getSelection();
+ if (checked == true) {
+ // TODO: This should NOT change the configuration immediately -
+ // it should set an intermediate variable and wait for OK/Apply
+ parent.getSelectedConfiguration().setBuildCommand(null);
+ parent.getSelectedConfiguration().setBuildArguments(null);
+ makeCommandEntry.setEditable(false);
+ } else {
+ makeCommandEntry.setEditable(true);
+ }
+ setValues();
+ }
+
+ /**
+ * Sets the "dirty" state
+ */
+ public void setDirty(boolean b) {
+ dirty = b;
+ }
+
+ /**
+ * Returns the "dirty" state
+ */
+ public boolean isDirty() {
+ return dirty;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ErrorParserBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ErrorParserBlock.java
index 58008294ad9..e45477eba68 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ErrorParserBlock.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ErrorParserBlock.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * Copyright (c) 2002,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -12,75 +12,119 @@
package org.eclipse.cdt.managedbuilder.internal.ui;
import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.ui.wizards.NewManagedProjectOptionPage;
import org.eclipse.cdt.managedbuilder.ui.wizards.NewManagedProjectWizard;
import org.eclipse.cdt.ui.dialogs.AbstractErrorParserBlock;
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.preference.IPreferenceStore;
public class ErrorParserBlock extends AbstractErrorParserBlock {
public ErrorParserBlock() {
- super(null);
+ super();
}
- protected String[] getErrorParserIDs(ITarget target) {
- // Get the list of error parsers specified with this Target
- String[] errorParsers = target.getErrorParserList();
+ protected String[] getErrorParserIDs(IConfiguration config) {
+ // Get the list of error parsers specified with this Configuration
+ String[] errorParsers = config.getErrorParserList();
if (errorParsers != null) {
return errorParsers;
}
else {
- // If no error parsers are specified by the target, the default is
+ // If no error parsers are specified by the configuration, the default is
// all error parsers
return CCorePlugin.getDefault().getAllErrorParsersIDs();
}
}
protected String[] getErrorParserIDs(IProject project) {
- ITarget target = ManagedBuildManager.getSelectedTarget(project);
- if (target == null) {
+ IConfiguration config = ManagedBuildManager.getSelectedConfiguration(project);
+ if (config == null) {
// This case occurs when modifying the properties of an existing
// managed build project, and the user selects the error parsers
// page before the "C/C++ Build" page.
// Get the build information
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- target = info.getDefaultTarget();
+ config = info.getDefaultConfiguration();
}
- if (target != null) {
- return getErrorParserIDs(target);
+ if (config != null) {
+ return getErrorParserIDs(config);
} else {
return CCorePlugin.getDefault().getAllErrorParsersIDs();
}
}
protected String[] getErrorParserIDs() {
- // Get the currently selected target from the page's container
+ // Get the currently selected configuration from the page's container
// This is invoked by the managed builder new project wizard before the
// project is created.
ICOptionContainer container = getContainer();
if (container instanceof NewManagedProjectOptionPage) {
NewManagedProjectOptionPage parent = (NewManagedProjectOptionPage)getContainer();
NewManagedProjectWizard wizard = (NewManagedProjectWizard)parent.getWizard();
- ITarget target = wizard.getSelectedTarget();
- return getErrorParserIDs(target);
+ // TODO: This is wrong since the Wizard does not have a selected configuration!
+ IProjectType proj = wizard.getSelectedProjectType();
+ IConfiguration[] configs = proj.getConfigurations();
+ if (configs.length > 0)
+ return getErrorParserIDs(configs[0]);
+ else
+ return new String[0];
}
return CCorePlugin.getDefault().getAllErrorParsersIDs();
}
public void saveErrorParsers(IProject project, String[] parsers) {
- ITarget target = ManagedBuildManager.getSelectedTarget(project);
- if (target != null) {
+ IConfiguration config = ManagedBuildManager.getSelectedConfiguration(project);
+ if (config != null) {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < parsers.length; i++) {
if (i > 0) buf.append(';');
buf.append(parsers[i]);
}
- target.setErrorParserIds(buf.toString());
+ config.setErrorParserIds(buf.toString());
}
}
+
+ public IPreferenceStore getPreferenceStore() {
+ return null;
+ }
+
+ protected void setValues() {
+ super.setValues();
+
+ // TODO: This reset belongs in AbstractErrorParserBlock.java?
+ // Reset the "dirty" flag
+ listDirty = false;
+ }
+
+ public void performApply(IProgressMonitor monitor) throws CoreException {
+ super.performApply(monitor);
+
+ // TODO: This reset belongs in AbstractErrorParserBlock.java?
+ // Reset the "dirty" flag
+ listDirty = false;
+
+ }
+
+ /**
+ * Sets the "dirty" state
+ */
+ public void setDirty(boolean b) {
+ listDirty = b;
+ }
+
+ /**
+ * Returns the "dirty" state
+ */
+ public boolean isDirty() {
+ return listDirty;
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuildOptionBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuildOptionBlock.java
new file mode 100644
index 00000000000..5cb78b16089
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuildOptionBlock.java
@@ -0,0 +1,271 @@
+/**********************************************************************
+ * Copyright (c) 2002,2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ * **********************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.ui;
+
+import java.util.Iterator;
+
+import org.eclipse.cdt.ui.dialogs.BinaryParserBlock;
+import org.eclipse.cdt.ui.dialogs.ICOptionPage;
+import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
+import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
+import org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.ui.help.WorkbenchHelp;
+
+public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
+
+ private ToolsSettingsBlock toolsSettingsBlock;
+ private BuildSettingsBlock buildSettingsBlock;
+ private ErrorParserBlock errParserBlock;
+ private BinaryParserBlock binaryParserBlock;
+ private Object element;
+
+ /**
+ * @param parent
+ */
+ public ManagedBuildOptionBlock(BuildPropertyPage parent) {
+ super(parent, false);
+ }
+
+ public ManagedBuildOptionBlock(ResourceBuildPropertyPage resParent) {
+ super(resParent, false);
+ }
+
+ public BuildPropertyPage getBuildPropertyPage() {
+ return (BuildPropertyPage)fParent;
+ }
+
+ public ResourceBuildPropertyPage getResourceBuildPropertyPage() {
+ return (ResourceBuildPropertyPage)fParent;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock#addTabs()
+ */
+ protected void addTabs() {
+
+ if (element instanceof IProject) {
+ addTab(toolsSettingsBlock = new ToolsSettingsBlock((BuildPropertyPage) fParent, element));
+ addTab(buildSettingsBlock = new BuildSettingsBlock((BuildPropertyPage) fParent));
+ addTab(errParserBlock = new ErrorParserBlock());
+ addTab(binaryParserBlock = new BinaryParserBlock());
+ } else if (element instanceof IFile) {
+ addTab(toolsSettingsBlock = new ToolsSettingsBlock((ResourceBuildPropertyPage) fParent, element));
+ }
+ }
+
+ public ToolsSettingsBlock getToolsSettingsBlock() {
+ return toolsSettingsBlock;
+ }
+
+ public BuildSettingsBlock getBuildSettingsBlock() {
+ return buildSettingsBlock;
+ }
+
+ public BinaryParserBlock getBinaryParserBlock() {
+ return binaryParserBlock;
+ }
+
+ public ErrorParserBlock getErrorParserBlock() {
+ return errParserBlock;
+ }
+
+ public Control createContents(Composite parent, Object element) {
+ this.element = element;
+ Control control = super.createContents( parent );
+ ((GridLayout)((Composite)control).getLayout()).marginWidth = 1;
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ ((Composite)control).setLayoutData(gd);
+
+ // TODO
+ //if (getToolsSettingsBlock() != null)
+ // WorkbenchHelp.setHelp(getToolsSettingsBlock().getControl(), ManagedBuilderHelpContextIds.MAN_PROJ_ERROR_PARSER);
+ if (getErrorParserBlock() != null)
+ WorkbenchHelp.setHelp(getErrorParserBlock().getControl(), ManagedBuilderHelpContextIds.MAN_PROJ_ERROR_PARSER);
+
+ return control;
+ }
+
+ protected void initializeValues() {
+ if (getToolsSettingsBlock()!= null) {
+ getToolsSettingsBlock().initializeValues();
+ }
+ if (getBuildSettingsBlock()!= null) {
+ getBuildSettingsBlock().initializeValues();
+ }
+ if (getErrorParserBlock()!= null) {
+ // TODO
+ //getErrorParserBlock().initializeValues();
+ }
+ if (getBinaryParserBlock()!= null) {
+ // TODO
+ //getBinaryParserBlock().initializeValues();
+ }
+ }
+
+ public void updateValues() {
+ if (element instanceof IProject) {
+ if (getToolsSettingsBlock() != null) {
+ getToolsSettingsBlock().updateValues();
+ }
+ if (getBuildSettingsBlock() != null) {
+ getBuildSettingsBlock().updateValues();
+ }
+ if (getErrorParserBlock() != null) {
+ getErrorParserBlock().updateValues();
+ }
+ if (getBinaryParserBlock() != null) {
+ // TODO
+ //getBinaryParserBlock().updateValues();
+ }
+ } else if( element instanceof IFile) {
+ if (getToolsSettingsBlock() != null) {
+ getToolsSettingsBlock().updateValues();
+ }
+ }
+ }
+
+ public void setValues() {
+ if (element instanceof IProject) {
+ if (getToolsSettingsBlock() != null) {
+ getToolsSettingsBlock().updateValues();
+ }
+ if (getBuildSettingsBlock() != null) {
+ getBuildSettingsBlock().setValues();
+ }
+ if (getErrorParserBlock() != null) {
+ // TODO
+ //getErrorParserBlock().setValues();
+ }
+ if (getBinaryParserBlock() != null) {
+ // TODO
+ //getBinaryParserBlock().setValues();
+ }
+ } else if (element instanceof IFile) {
+ if (getToolsSettingsBlock() != null) {
+ getToolsSettingsBlock().updateValues();
+ }
+ }
+ }
+
+ public void removeValues(String id) {
+ if (element instanceof IProject) {
+ if (getToolsSettingsBlock() != null) {
+ getToolsSettingsBlock().removeValues(id);
+ }
+ if (getBuildSettingsBlock() != null) {
+ getBuildSettingsBlock().removeValues(id);
+ }
+ if (getErrorParserBlock() != null) {
+ // TODO
+ //getErrorParserBlock().removeValues(id);
+ }
+ if (getBinaryParserBlock() != null) {
+ // TODO
+ //getBinaryParserBlock().removeValues(id);
+ }
+ } else if (element instanceof IFile) {
+ if (getToolsSettingsBlock()!= null) {
+ getToolsSettingsBlock().removeValues(id);
+ }
+ }
+ }
+
+ public IPreferenceStore getPreferenceStore()
+ {
+ if (element instanceof IProject) {
+ if (getCurrentPage() instanceof ToolsSettingsBlock) {
+ return toolsSettingsBlock.getPreferenceStore();
+ }
+ if (getCurrentPage() instanceof BuildSettingsBlock) {
+ return buildSettingsBlock.getPreferenceStore();
+ }
+ if (getCurrentPage() instanceof ErrorParserBlock) {
+ return errParserBlock.getPreferenceStore();
+ }
+ if (getCurrentPage() instanceof BinaryParserBlock) {
+ return null;
+ }
+ } else if( element instanceof IFile) {
+ if (getCurrentPage() instanceof ToolsSettingsBlock) {
+ return toolsSettingsBlock.getPreferenceStore();
+ }
+ }
+ return null;
+ }
+
+ public IPreferenceStore getToolSettingsPreferenceStore()
+ {
+ return toolsSettingsBlock.getPreferenceStore();
+ }
+
+ public void update() {
+ super.update();
+ ICOptionPage tab = getCurrentPage();
+ // Currently, other settings are per-config, while binary parser settings are per-project
+ if (tab instanceof BinaryParserBlock) {
+ ((BuildPropertyPage)fParent).enableConfigSelection(false);
+ } else {
+ if(element instanceof IProject) {
+ ((BuildPropertyPage)fParent).enableConfigSelection(true);
+ } else if ( element instanceof IFile) {
+ ((ResourceBuildPropertyPage)fParent).enableConfigSelection(true);
+ }
+ }
+ }
+
+ /**
+ * Sets the dirty state of the contained pages
+ */
+ public void setDirty(boolean b) {
+ Iterator iter = getOptionPages().iterator();
+ while (iter.hasNext()) {
+ ICOptionPage tab = (ICOptionPage)iter.next();
+ if (tab instanceof BuildSettingsBlock) {
+ ((BuildSettingsBlock)tab).setDirty(b);
+ } else if (tab instanceof ToolsSettingsBlock) {
+ ((ToolsSettingsBlock)tab).setDirty(b);
+ } else if (tab instanceof ErrorParserBlock) {
+ ((ErrorParserBlock)tab).setDirty(b);
+ } else if (tab instanceof BinaryParserBlock) {
+ //TODO ManagedBuildSystem needs its own binary parser block
+ }
+ }
+ }
+
+ /**
+ * Returns <code> true <code/> if any of the pages are dirty
+ * @return boolean
+ */
+ public boolean isDirty() {
+ Iterator iter = getOptionPages().iterator();
+ while (iter.hasNext()) {
+ ICOptionPage tab = (ICOptionPage)iter.next();
+ if (tab instanceof BuildSettingsBlock) {
+ if (((BuildSettingsBlock)tab).isDirty()) return true;
+ } else if (tab instanceof ToolsSettingsBlock) {
+ if (((ToolsSettingsBlock)tab).isDirty()) return true;
+ } else if (tab instanceof ErrorParserBlock) {
+ if (((ErrorParserBlock)tab).isDirty()) return true;
+ } else if (tab instanceof BinaryParserBlock) {
+ //TODO ManagedBuildSystem needs its own binary parser block
+ }
+
+ }
+ return false;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedMakeStartup.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedMakeStartup.java
deleted file mode 100644
index e4954e03d6a..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedMakeStartup.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui;
-
-import org.eclipse.cdt.managedbuilder.ui.actions.UpdateManagedProjectAction;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IStartup;
-
-/**
- *
- */
-public class ManagedMakeStartup implements IStartup {
- /* (non-Javadoc)
- * @see org.eclipse.ui.IStartup#earlyStartup()
- */
- public void earlyStartup() {
- // Get any 1.2 projects from the workspace
- final IProject[] projects = UpdateManagedProjectAction.getVersion12Projects();
- if (projects.length > 0) {
- Display.getDefault().asyncExec(new Runnable() {
- // Start the process that will update the 1.2 projects
- public void run() {
- Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
- for (int index = projects.length - 1; index >= 0; --index) {
- IProject project = projects[index];
- boolean shouldUpdate = MessageDialog.openQuestion(shell,
- ManagedBuilderUIMessages.getResourceString("ManagedBuilderStartup.update.12x.title"), //$NON-NLS-1$
- ManagedBuilderUIMessages.getFormattedString("ManagedBuilderStartup.update.12x.message", new String[]{project.getName()})); //$NON-NLS-1$
- // Go for it
- if (shouldUpdate) {
- ProgressMonitorDialog pd = new ProgressMonitorDialog(shell);
- UpdateManagedProjectAction.run(false, pd, project);
- }
- }
-
- }
- });
- }
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedProjectOptionBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedProjectOptionBlock.java
index 02cc74db91f..8579d0b4571 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedProjectOptionBlock.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedProjectOptionBlock.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.internal.ui;
-
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * Copyright (c) 2002,2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,10 +8,13 @@ package org.eclipse.cdt.managedbuilder.internal.ui;
* Contributors:
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.ui;
import org.eclipse.cdt.ui.dialogs.BinaryParserBlock;
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.help.WorkbenchHelp;
@@ -27,7 +28,7 @@ public class ManagedProjectOptionBlock extends TabFolderOptionBlock {
* @param parent
*/
public ManagedProjectOptionBlock(ICOptionContainer parent) {
- super(parent);
+ super(parent, false);
}
/* (non-Javadoc)
@@ -49,9 +50,27 @@ public class ManagedProjectOptionBlock extends TabFolderOptionBlock {
public Control createContents(Composite parent) {
Control control = super.createContents( parent );
+ ((GridLayout)((Composite)control).getLayout()).marginWidth = 1;
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ ((Composite)control).setLayoutData(gd);
+
if (getErrorParserBlock()!= null)
WorkbenchHelp.setHelp(getErrorParserBlock().getControl(), ManagedBuilderHelpContextIds.MAN_PROJ_ERROR_PARSER);
return control;
}
+
+ public void updateValues() {
+ if (getErrorParserBlock()!= null) {
+ getErrorParserBlock().updateValues();
+ }
+ if (getBinaryParserBlock()!= null) {
+ // TODO
+ //getBinaryParserBlock().updateValues();
+ }
+ }
+
+ public void update() {
+ super.update();
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties
index 86749492e38..706c7b43a46 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties
@@ -3,16 +3,9 @@
# All Rights Reserved.
#########################################
-# ------- 1.2 Project Update Messages -------
-ManagedBuilderStartup.update.12x.title=Update Managed Builder Project
-ManagedBuilderStartup.update.12x.message=The project {0} has been detected in your workspace.\n Its build settings are stored in a format that is no longer supported.\n Would you like to convert them now?
-ManagedBuilderStartup.update.exception.error=Error
-ManagedBuilderStartup.update.exception.message=Error updating project {0}
-ManagedBuildConvert.12x.monitor.message.project=Updating build settings for project {0}
-ManagedBuildConvert.12x.monitor.message.backup=Backing up the settings file for {0}
-ManagedBuildConvert.12x.warning.title=Backup File Already Exists
-ManagedBuildConvert.12x.warning.message=A backup file already exists for the project {0}.\n Shall I try to convert the project anyway?
-ManagedBuildConvert.12x.cancelled.message=The update operation has been cancelled.\n The build system will not be able to read the project settings until you update the project.
+# ------- Project Update Messages -------
+ManagedBuilderStartup.update.20x.title=Update Managed Builder Project
+ManagedBuilderStartup.update.20x.message=The project {0} has been detected in your workspace.\n Its build settings are stored in a format that is no longer supported.\n Would you like to convert them now?
# ------- NewProjectCreationPluginPage-------
MngMakeProjectWizard.op_error=Managed Make Error
@@ -36,12 +29,12 @@ MngCCWizardSettings.title=Managed Make C++ Settings
MngCCWizardSettings.description=Define the Managed Make C++ build settings.
# -- Strings for the platform selection page --
-MngMakeProjectWizard.config.title=Select a Target
+MngMakeProjectWizard.config.title=Select a type of project
MngMakeProjectWizard.config.desc=Select the platform and configurations you wish to deploy on
-PlatformBlock.tip.platform=Select the target of the build goal
-PlatformBlock.label.platform=Build Target:
+PlatformBlock.tip.platform=Select the type of project for the build goal
+PlatformBlock.label.platform=Project Type:
PlatformBlock.label.configs=Configurations:
-PlatformBlock.label.showall=Show All Targets
+PlatformBlock.label.showall=Show All Project Types
PlatformBlock.message.error.noconfigs=You must select at least one configuration
# -- Strings for the additional options tab
@@ -49,14 +42,12 @@ MngMakeProjectWizard.options.title=Additional Project Settings
MngMakeProjectWizard.options.desc=Define the inter-project dependencies, if any.
# ----------- Configuration Selection Page -----------
-BuildPropertyPage.label.Platform=Platform:
+BuildPropertyPage.label.Platform=Project Type:
BuildPropertyPage.label.Configuration=Configuration:
BuildPropertyPage.label.Active=Active configuration
-BuildPropertyPage.label.Settings=Configuration settings
+BuildPropertyPage.label.Settings=Configuration Settings
BuildPropertyPage.label.AddConfButton=Manage...
BuildPropertyPage.selection.configuration.all=All configurations
-BuildPropertyPage.label.ToolTree=Tools
-BuildPropertyPage.label.ToolOptions=Options
BuildPropertyPage.tip.platform=Select a platform for the project
BuildPropertyPage.tip.config=Select the configuration to edit
BuildPropertyPage.tip.addconf=Add configurations for the platform
@@ -64,6 +55,37 @@ BuildPropertyPage.tip.remconf=Remove configurations for the platform
BuildPropertyPage.manage.title=Manage
BuildPropertyPage.error.Unknown_tree_element=Unknown type of element in tree of type {0}
BuildPropertyPage.error.version_low=The project settings are stored in an earlier format.\nYou must upgrade the project before the settings can be upgraded.
+BuildPropertyPage.defaults.title=Reset Configuration Tools
+BuildPropertyPage.defaults.message=This action will reset all of the tools in the selected configuration to their default settings.\n\nDo you want to proceed?
+BuildPropertyPage.changes.save.title=Apply Configuration Changes
+BuildPropertyPage.changes.save.question=You have made changes to the {0} configuration.\n\nDo you want to apply these changes before switching to the {1} configuration?
+BuildPropertyPage.changes.save.error=The configuration changes could not be applied.
+
+#--------------- Resource Configuration Selection Page --------------
+ResourceBuildPropertyPage.defaults.title=Reset Resource Configuration Tool
+ResourceBuildPropertyPage.defaults.message=This action will reset all options of the tool in the current resource configuration to their default settings.\n\nDo you want to proceed?
+
+# ----------- Tools Settings Block -----------
+ToolsSettingsBlock.label.Settings=Tool Settings
+ToolsSettingsBlock.label.ToolTree=Tools
+ToolsSettingsBlock.label.ToolOptions=Options
+
+# ----------- Build Settings Block -----------
+BuildSettingsBlock.label.Settings=Build Settings
+BuildSettingsBlock.label.makecmdgroup=Make command
+BuildSettingsBlock.label.makecmddef=Use default command
+BuildSettingsBlock.label.output.group=Build output
+BuildSettingsBlock.label.output.name=Artifact name:
+BuildSettingsBlock.label.output.extension=Artifact extension:
+
+# ------------Resource Configuration Selection Page
+ResourceBuildPropertyPage.label.ActiveResource=Active Resource configuration
+ResourceBuildPropertyPage.label.ResourceSettings=Resource Configuration settings
+ResourceBuildPropertyPage.label.Configuration=Configuration:
+ResourceBuildPropertyPage.label.ExcludeCheckBox= Exclude from build
+ResourceBuildPropertyPage.selection.configuration.all=All configurations
+ResourceBuildPropertyPage.label.ToolTree=Tools
+ResourceBuildPropertyPage.label.ToolOptions=Options
# ----------- Entry Dialog -----------
BrowseEntryDialog.error.Folder_name_invalid = Folder name invalid
@@ -81,11 +103,6 @@ NewConfiguration.error.title=Error
NewConfiguration.error.duplicateName=A configuration named "{0}" already exists.
# ----------- Target/Config management dialog -----------------
-ManageConfig.label.makecmdgroup=Make command
-ManageConfig.label.makecmddef=Use default command
-ManageConfig.label.output.group=Build output
-ManageConfig.label.output.name=Artifact name:
-ManageConfig.label.output.extension=Artifact extension:
ManageConfig.label.configs=Manage configurations
ManageConfig.label.restore=Restore
ManageConfig.label.configs.current=Current:
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ToolsSettingsBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ToolsSettingsBlock.java
new file mode 100644
index 00000000000..2da2a71f429
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ToolsSettingsBlock.java
@@ -0,0 +1,639 @@
+/**********************************************************************
+ * Copyright (c) 2002,2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * QNX Software Systems - Move to Make plugin
+ * Intel Corp - Use in Managed Make system
+***********************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.ui;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
+import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
+import org.eclipse.cdt.managedbuilder.ui.properties.BuildOptionSettingsPage;
+import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
+import org.eclipse.cdt.managedbuilder.ui.properties.BuildSettingsPage;
+import org.eclipse.cdt.managedbuilder.ui.properties.BuildToolSettingsPage;
+import org.eclipse.cdt.managedbuilder.ui.properties.BuildToolsSettingsStore;
+import org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage;
+import org.eclipse.cdt.managedbuilder.ui.properties.ToolListContentProvider;
+import org.eclipse.cdt.managedbuilder.ui.properties.ToolListLabelProvider;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Layout;
+import org.eclipse.swt.widgets.Shell;
+
+public class ToolsSettingsBlock extends AbstractCOptionPage {
+
+ /*
+ * String constants
+ */
+ private static final String PREFIX = "ToolsSettingsBlock"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String SETTINGS_LABEL = LABEL + ".Settings"; //$NON-NLS-1$
+ private static final String TREE_LABEL = LABEL + ".ToolTree"; //$NON-NLS-1$
+ private static final String OPTIONS_LABEL = LABEL + ".ToolOptions"; //$NON-NLS-1$
+ private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { 20, 30 };
+
+ /*
+ * Dialog widgets
+ */
+ private TreeViewer optionList;
+ private SashForm sashForm;
+ private Group sashGroup;
+ private Composite settingsPageContainer;
+ private ScrolledComposite containerSC;
+
+ /*
+ * Bookeeping variables
+ */
+ private Map configToPageListMap;
+ private BuildToolsSettingsStore settingsStore;
+ private Map settingsStoreMap;
+ private BuildPropertyPage parent;
+ private ResourceBuildPropertyPage resParent;
+ private BuildSettingsPage currentSettingsPage;
+ private IOptionCategory selectedCategory;
+ private ToolListContentProvider provider;
+ private ITool selectedTool;
+ private Object element;
+
+ /**
+ * The minimum page size; 200 by 200 by default.
+ *
+ * @see #setMinimumPageSize
+ */
+ private Point minimumPageSize = new Point(200, 200);
+
+ /**
+ * Layout for the page container.
+ *
+ */
+ private class PageLayout extends Layout {
+ public void layout(Composite composite, boolean force) {
+ Rectangle rect = composite.getClientArea();
+ Control[] children = composite.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ children[i].setSize(rect.width, rect.height);
+ }
+ }
+ public Point computeSize(Composite composite, int wHint, int hHint, boolean force) {
+ if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
+ return new Point(wHint, hHint);
+ }
+ int x = minimumPageSize.x;
+ int y = minimumPageSize.y;
+
+ Control[] children = composite.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ Point size = children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
+ x = Math.max(x, size.x);
+ y = Math.max(y, size.y);
+ }
+ if (wHint != SWT.DEFAULT) {
+ x = wHint;
+ }
+ if (hHint != SWT.DEFAULT) {
+ y = hHint;
+ }
+ return new Point(x, y);
+ }
+ }
+
+ /*
+ * Constructor
+ */
+ public ToolsSettingsBlock(BuildPropertyPage parent, Object element)
+ {
+ super(ManagedBuilderUIMessages.getResourceString(SETTINGS_LABEL));
+ super.setContainer(parent);
+ this.parent = parent;
+ configToPageListMap = new HashMap();
+ this.element = element;
+ }
+
+ public ToolsSettingsBlock(ResourceBuildPropertyPage resParent, Object element)
+ {
+ super(ManagedBuilderUIMessages.getResourceString(SETTINGS_LABEL));
+ super.setContainer((ICOptionContainer) resParent);
+ this.resParent = resParent;
+ configToPageListMap = new HashMap();
+ this.element = element;
+ }
+
+ public void createControl(Composite parent) {
+
+ // Create the sash form
+ sashForm = new SashForm(parent, SWT.NONE);
+ sashForm.setOrientation(SWT.HORIZONTAL);
+ sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 5;
+ layout.marginWidth = 5;
+ sashForm.setLayout(layout);
+
+ setControl(sashForm);
+ createSelectionArea(sashForm);
+ createEditArea(sashForm);
+ initializeSashForm();
+
+ //WorkbenchHelp.setHelp(composite, ManagedBuilderHelpContextIds.MAN_PROJ_BUILD_PROP);
+ }
+
+ protected void createSelectionArea (Composite parent) {
+ // Create a label and list viewer
+ Composite composite = ControlFactory.createComposite(parent, 1);
+ optionList = new TreeViewer(composite, SWT.SINGLE|SWT.H_SCROLL|SWT.V_SCROLL|SWT.BORDER);
+ optionList.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleOptionSelection();
+ }
+ });
+ optionList.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
+ optionList.setLabelProvider(new ToolListLabelProvider());
+ }
+
+ /* (non-Javadoc)
+ * Method displayOptionsForTool.
+ * @param toolReference
+ */
+ private void displayOptionsForCategory(IOptionCategory category) {
+ // Do nothing if the selected category is is unchanged
+ if (category == selectedCategory) {
+ return;
+ }
+ selectedTool = null;
+ selectedCategory = category;
+
+ // Cache the current build setting page
+ BuildSettingsPage oldPage = currentSettingsPage;
+ currentSettingsPage = null;
+
+ // Create a new settings page if necessary
+ List pages = getPagesForConfig();
+ ListIterator iter = pages.listIterator();
+ while (iter.hasNext()) {
+ BuildSettingsPage page = (BuildSettingsPage) iter.next();
+ if (page instanceof BuildOptionSettingsPage &&
+ ((BuildOptionSettingsPage)page).isForCategory(category)) {
+ currentSettingsPage = page;
+ break;
+ }
+ }
+ if (currentSettingsPage == null) {
+ if ( this.element instanceof IProject) {
+ currentSettingsPage = new BuildOptionSettingsPage(parent.getSelectedConfiguration(), category);
+ pages.add(currentSettingsPage);
+ currentSettingsPage.setContainer(parent);
+ } else if ( this.element instanceof IFile) {
+ currentSettingsPage = new BuildOptionSettingsPage(resParent.getCurrentResourceConfig(), category);
+ pages.add(currentSettingsPage);
+ currentSettingsPage.setContainer(resParent);
+ }
+ if (currentSettingsPage.getControl() == null) {
+ currentSettingsPage.createControl(settingsPageContainer);
+ }
+ }
+
+ // Make all the other pages invisible
+ Control[] children = settingsPageContainer.getChildren();
+ Control currentControl = currentSettingsPage.getControl();
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] != currentControl)
+ children[i].setVisible(false);
+ }
+ currentSettingsPage.setVisible(true);
+
+ // save the last page build options.
+ // If the last page is tool page then parse all the options
+ // and put it in the appropriate preference store.
+ if (oldPage != null){
+ if(oldPage instanceof BuildOptionSettingsPage) {
+ ((BuildOptionSettingsPage)oldPage).storeSettings();
+ }
+ else if(oldPage instanceof BuildToolSettingsPage) {
+ ((BuildToolSettingsPage)oldPage).storeSettings();
+ //((BuildToolSettingsPage)oldPage).parseAllOptions();
+ }
+ }
+ //update the field editors in the current page
+ if(currentSettingsPage instanceof BuildOptionSettingsPage)
+ ((BuildOptionSettingsPage)currentSettingsPage).updateFields();
+
+ if (oldPage != null)
+ oldPage.setVisible(false);
+
+ // Set the size of the scrolled area
+ containerSC.setMinSize(currentSettingsPage.computeSize());
+ settingsPageContainer.layout();
+ }
+
+ /* (non-Javadoc)
+ * @param tool
+ */
+ private void displayOptionsForTool(ITool tool) {
+ if (tool == selectedTool) {
+ return;
+ }
+ // Unselect the category
+ selectedCategory = null;
+ // record that the tool selection has changed
+ selectedTool = tool;
+
+ // Cache the current build setting page
+ BuildSettingsPage oldPage = currentSettingsPage;
+ currentSettingsPage = null;
+
+ // Create a new page if we need one
+ List pages = getPagesForConfig();
+ ListIterator iter = pages.listIterator();
+ while (iter.hasNext()) {
+ BuildSettingsPage page = (BuildSettingsPage) iter.next();
+ if (page instanceof BuildToolSettingsPage &&
+ ((BuildToolSettingsPage)page).isForTool(tool)) {
+ currentSettingsPage = page;
+ break;
+ }
+ }
+ if (currentSettingsPage == null) {
+ if ( this.element instanceof IProject) {
+ currentSettingsPage = new BuildToolSettingsPage(parent.getSelectedConfiguration(), tool);
+ pages.add(currentSettingsPage);
+ currentSettingsPage.setContainer(parent);
+ } else if(this.element instanceof IFile) {
+ currentSettingsPage = new BuildToolSettingsPage(resParent.getCurrentResourceConfig(), tool);
+ pages.add(currentSettingsPage);
+ currentSettingsPage.setContainer(resParent);
+ }
+ if (currentSettingsPage.getControl() == null) {
+ currentSettingsPage.createControl(settingsPageContainer);
+ }
+ }
+ // Make all the other pages invisible
+ Control[] children = settingsPageContainer.getChildren();
+ Control currentControl = currentSettingsPage.getControl();
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] != currentControl)
+ children[i].setVisible(false);
+ }
+
+ // Make the current page visible
+ currentSettingsPage.setVisible(true);
+
+ // save the last page build options.
+ // If the last page is tool page then parse all the options
+ // and put it in the appropriate preference store.
+ if (oldPage != null){
+ if(oldPage instanceof BuildOptionSettingsPage) {
+ ((BuildOptionSettingsPage)oldPage).storeSettings();
+ }
+ else if(oldPage instanceof BuildToolSettingsPage) {
+ ((BuildToolSettingsPage)oldPage).storeSettings();
+ //((BuildToolSettingsPage)oldPage).parseAllOptions();
+ }
+ }
+ //update the field editor that displays all the build options
+ if(currentSettingsPage instanceof BuildToolSettingsPage)
+ ((BuildToolSettingsPage)currentSettingsPage).updateAllOptionField();
+
+ if (oldPage != null)
+ oldPage.setVisible(false);
+
+ // Set the size of the scrolled area
+ containerSC.setMinSize(currentSettingsPage.computeSize());
+ settingsPageContainer.layout();
+ }
+
+ /* (non-Javadoc)
+ * Add the tabs relevant to the project to edit area tab folder.
+ */
+ protected void createEditArea(Composite parent) {
+ containerSC = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
+ containerSC.setExpandHorizontal(true);
+ containerSC.setExpandVertical(true);
+
+ // Add a container for the build settings page
+ settingsPageContainer = new Composite(containerSC, SWT.NULL);
+ settingsPageContainer.setLayout(new PageLayout());
+
+ containerSC.setContent(settingsPageContainer);
+ containerSC.setMinSize(settingsPageContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ settingsPageContainer.layout();
+ }
+
+ /*
+ * (non-javadoc)
+ * Initialize the relative weights (widths) of the 2 sides of the sash.
+ */
+ protected void initializeSashForm() {
+ sashForm.setWeights(DEFAULT_SASH_WEIGHTS);
+ }
+
+ protected void initializeValues() {
+ setValues();
+ }
+
+ public void updateValues() {
+ setValues();
+ }
+
+ protected void setValues() {
+
+ if (provider == null) {
+// IResource element = parent.getProject();
+ IResource resource = (IResource) element;
+ provider = new ToolListContentProvider(resource.getType());
+ optionList.setContentProvider(provider);
+ }
+ if ( element instanceof IProject ) {
+ optionList.setInput(parent.getSelectedConfiguration());
+ } else if ( element instanceof IFile){
+ optionList.setInput(resParent.getCurrentResourceConfig());
+ }
+
+ optionList.expandAll();
+
+ // Create (or retrieve) the settings store for the configuration/resource configuration
+ BuildToolsSettingsStore store = null;
+ if ( element instanceof IProject ) {
+ store = (BuildToolsSettingsStore) getSettingsStoreMap().get(parent.getSelectedConfiguration().getId());
+ if (store == null) {
+ store = new BuildToolsSettingsStore(parent.getSelectedConfiguration());
+ getSettingsStoreMap().put(parent.getSelectedConfiguration().getId(), store);
+ }
+ } else if ( element instanceof IFile) {
+ store = (BuildToolsSettingsStore) getSettingsStoreMap().get(resParent.getCurrentResourceConfig().getId());
+ if (store == null) {
+ store = new BuildToolsSettingsStore(resParent.getCurrentResourceConfig());
+ getSettingsStoreMap().put(resParent.getCurrentResourceConfig().getId(), store);
+ }
+ }
+ settingsStore = store;
+
+ // Select the first tool in the list
+ Object[] elements = null;
+ Object primary = null;
+ if( element instanceof IProject){
+ elements = provider.getElements(parent.getSelectedConfiguration());
+ } else if ( element instanceof IFile) {
+ elements = provider.getElements(resParent.getCurrentResourceConfig());
+ }
+ primary = elements.length > 0 ? elements[0] : null;
+
+ if (primary != null) {
+ optionList.setSelection(new StructuredSelection(primary));
+ }
+ }
+
+ public void removeValues(String id) {
+ getSettingsStoreMap().remove(id);
+ }
+
+ private void handleOptionSelection() {
+ // Get the selection from the tree list
+ IStructuredSelection selection = (IStructuredSelection) optionList.getSelection();
+
+ // Set the option page based on the selection
+ Object element = selection.getFirstElement();
+ if (element instanceof ITool) {
+ displayOptionsForTool((ITool)element);
+ } else if (element instanceof IOptionCategory) {
+ displayOptionsForCategory((IOptionCategory)element);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
+ */
+ public void performDefaults() {
+ if ( element instanceof IProject) {
+ performDefaults( (IProject)element);
+ } else if ( element instanceof IFile) {
+ performDefaults( (IFile)element);
+ }
+ return;
+ }
+
+ public void performDefaults(IProject project) {
+ // TODO: Should this reset all tools of the configuration, or just
+ // the currently selected tool category? Right now it is all tools.
+
+ // Display a "Confirm" dialog box, since:
+ // 1. The defaults are immediately applied
+ // 2. The action cannot be undone
+ Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
+ boolean shouldDefault = MessageDialog.openConfirm(shell,
+ ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.defaults.title"), //$NON-NLS-1$
+ ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.defaults.message")); //$NON-NLS-1$
+ if (!shouldDefault) return;
+
+ // Empty the page list
+ List pages = getPagesForConfig();
+ pages.clear();
+
+ // Get the build manager to reset build info for project
+ ManagedBuildManager.resetConfiguration(parent.getProject(), parent.getSelectedConfiguration());
+
+ // Recreate the settings store for the configuration
+ settingsStore = new BuildToolsSettingsStore(parent.getSelectedConfiguration());
+
+ // Write out the build model info
+ ManagedBuildManager.setDefaultConfiguration(parent.getProject(), parent.getSelectedConfiguration());
+ ManagedBuildManager.saveBuildInfo(parent.getProject(), false);
+
+ // Reset the category or tool selection and run selection event handler
+ selectedCategory = null;
+ selectedTool = null;
+ handleOptionSelection();
+
+ setDirty(false);
+ }
+
+ public void performDefaults(IFile file) {
+ // TODO: Should this reset all options of the tool in current resource configuration, or just
+ // the currently selected tool category? Right now it is all options.
+
+ // Display a "Confirm" dialog box, since:
+ // 1. The defaults are immediately applied
+ // 2. The action cannot be undone
+ Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
+ boolean shouldDefault = MessageDialog.openConfirm(shell,
+ ManagedBuilderUIMessages.getResourceString("ResourceBuildPropertyPage.defaults.title"), //$NON-NLS-1$
+ ManagedBuilderUIMessages.getResourceString("ResourceBuildPropertyPage.defaults.message")); //$NON-NLS-1$
+ if (!shouldDefault) return;
+
+ // Empty the page list
+ List pages = getPagesForConfig();
+ pages.clear();
+
+ // Get the build manager to reset build info for project
+ ManagedBuildManager.resetResourceConfiguration(resParent.getProject(), resParent.getCurrentResourceConfig());
+
+ // Recreate the settings store for the configuration
+ settingsStore = new BuildToolsSettingsStore(resParent.getCurrentResourceConfig());
+
+ // Write out the build model info
+ ManagedBuildManager.setDefaultConfiguration(resParent.getProject(), resParent.getSelectedConfiguration());
+ ManagedBuildManager.saveBuildInfo(resParent.getProject(), false);
+
+ // Reset the category or tool selection and run selection event handler
+ selectedCategory = null;
+ selectedTool = null;
+ handleOptionSelection();
+
+ setDirty(false);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(IProgressMonitor)
+ */
+ public void performApply(IProgressMonitor monitor) throws CoreException {
+
+ // Force each settings page to update
+ List pages = getPagesForConfig();
+ // Make sure we have something to work on
+ if (pages == null) {
+ // Nothing to do
+ return;
+ }
+ ListIterator iter = pages.listIterator();
+ while (iter.hasNext()) {
+ BuildSettingsPage page = (BuildSettingsPage) iter.next();
+ if (page == null) continue;
+ if (page instanceof BuildToolSettingsPage) {
+ // if the currentsettings page is not the tool settings page
+ // then update the all build options field editor based on the
+ // build options in other options settings page.
+ if (!(currentSettingsPage instanceof BuildToolSettingsPage))
+ ((BuildToolSettingsPage)page).updateAllOptionField();
+ ((BuildToolSettingsPage)page).performOk();
+ } else if (page instanceof BuildOptionSettingsPage) {
+ ((BuildOptionSettingsPage)page).performOk();
+ }
+ }
+
+ setDirty(false);
+ }
+
+ /* (non-Javadoc)
+ * Answers the list of settings pages for the selected configuration
+ * @return
+ */
+ private List getPagesForConfig() {
+ List pages = null;
+ if ( element instanceof IProject) {
+// Make sure that something was selected
+ if (parent.getSelectedConfiguration() == null) {
+ return null;
+ }
+ pages = (List) configToPageListMap.get(parent.getSelectedConfiguration().getId());
+ } else if (element instanceof IFile) {
+ if ( resParent.getCurrentResourceConfig() == null ) {
+ return null;
+ }
+ pages = (List) configToPageListMap.get(resParent.getCurrentResourceConfig().getId());
+ }
+
+ if (pages == null) {
+ pages = new ArrayList();
+ if ( element instanceof IProject) {
+ configToPageListMap.put(parent.getSelectedConfiguration().getId(), pages);
+ } else if ( element instanceof IFile) {
+ configToPageListMap.put(resParent.getCurrentResourceConfig().getId(), pages);
+ }
+ }
+ return pages;
+ }
+
+ public IPreferenceStore getPreferenceStore() {
+ return settingsStore;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor method
+ *
+ * @return Returns the Map of configurations to preference stores.
+ */
+ protected Map getSettingsStoreMap() {
+ if (settingsStoreMap == null) {
+ settingsStoreMap = new HashMap();
+ }
+ return settingsStoreMap;
+ }
+
+ /**
+ * Sets the "dirty" state
+ */
+ public void setDirty(boolean b) {
+ // Set each settings page
+ List pages = getPagesForConfig();
+ // Make sure we have something to work on
+ if (pages == null) {
+ // Nothing to do
+ return;
+ }
+ ListIterator iter = pages.listIterator();
+ while (iter.hasNext()) {
+ BuildSettingsPage page = (BuildSettingsPage) iter.next();
+ if (page == null) continue;
+ page.setDirty(b);
+ }
+ }
+
+ /**
+ * Returns the "dirty" state
+ */
+ public boolean isDirty() {
+ // Check each settings page
+ List pages = getPagesForConfig();
+ // Make sure we have something to work on
+ if (pages == null) {
+ // Nothing to do
+ return false;
+ }
+ ListIterator iter = pages.listIterator();
+ while (iter.hasNext()) {
+ BuildSettingsPage page = (BuildSettingsPage) iter.next();
+ if (page == null) continue;
+ if (page.isDirty()) return true;
+ }
+ return false;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/UpdateManagedProjectAction.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/UpdateManagedProjectAction.java
deleted file mode 100644
index 35b568bf141..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/UpdateManagedProjectAction.java
+++ /dev/null
@@ -1,580 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.actions;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Random;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.FactoryConfigurationError;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.managedbuilder.core.BuildException;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IOption;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IToolReference;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
-import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-/**
- * @since 2.0
- */
-public class UpdateManagedProjectAction implements IWorkbenchWindowActionDelegate {
-
-
- private static final String ID_CYGWIN = "cygwin"; //$NON-NLS-1$
- private static final String ID_DEBUG = "debug"; //$NON-NLS-1$
- private static final String ID_DIRS = "dirs"; //$NON-NLS-1$
- private static final String ID_EXE = "exe"; //$NON-NLS-1$
- private static final String ID_EXEC = "exec"; //$NON-NLS-1$
- private static final String ID_GENERAL = "general"; //$NON-NLS-1$
- private static final String ID_GNU = "gnu"; //$NON-NLS-1$
- private static final String ID_INCPATHS = "incpaths"; //$NON-NLS-1$
- private static final String ID_INCLUDE = "include"; //$NON-NLS-1$
- private static final String ID_LINUX = "linux"; //$NON-NLS-1$
- private static final String ID_OPTION = "option"; //$NON-NLS-1$
- private static final String ID_OPTIONS = "options"; //$NON-NLS-1$
- private static final String ID_PATHS = "paths"; //$NON-NLS-1$
- private static final String ID_PREPROC = "preprocessor"; //$NON-NLS-1$
- private static final String ID_RELEASE = "release"; //$NON-NLS-1$
- private static final String ID_SEPARATOR = "."; //$NON-NLS-1$
- private static final String ID_SHARED = "so"; //$NON-NLS-1$
- private static final String ID_SOLARIS = "solaris"; //$NON-NLS-1$
- private static final String ID_STATIC = "lib"; //$NON-NLS-1$
- private static final String NEW_CONFIG_ROOT = "cdt.managedbuild.config.gnu"; //$NON-NLS-1$
- private static final String NEW_CYGWIN_TARGET_ROOT = "cdt.managedbuild.target.gnu.cygwin"; //$NON-NLS-1$
- private static final String NEW_POSIX_TARGET_ROOT = "cdt.managedbuild.target.gnu"; //$NON-NLS-1$
- private static final String NEW_TOOL_ROOT = "cdt.managedbuild.tool.gnu"; //$NON-NLS-1$
- private static final String TOOL_LANG_BOTH = "both"; //$NON-NLS-1$
- private static final String TOOL_LANG_C = "c"; //$NON-NLS-1$
- private static final String TOOL_LANG_CPP = "cpp"; //$NON-NLS-1$
- private static final String TOOL_NAME_AR = "ar"; //$NON-NLS-1$
- private static final String TOOL_NAME_ARCHIVER = "archiver"; //$NON-NLS-1$
- private static final String TOOL_NAME_COMPILER = "compiler"; //$NON-NLS-1$
- private static final String TOOL_NAME_LIB = "lib"; //$NON-NLS-1$
- private static final String TOOL_NAME_LINK = "link"; //$NON-NLS-1$
- private static final String TOOL_NAME_LINKER = "linker"; //$NON-NLS-1$
- private static final String TOOL_NAME_SOLINK = "solink"; //$NON-NLS-1$
- private static final int TOOL_TYPE_COMPILER = 0;
- private static final int TOOL_TYPE_LINKER = 1;
- private static final int TOOL_TYPE_ARCHIVER = 2;
- private static final int TYPE_EXE = 0;
- private static final int TYPE_SHARED = 1;
- private static final int TYPE_STATIC = 2;
-
- /* (non-Javadoc)
- * Create a back-up file containing the pre-2.0 project settings.
- *
- * @param settingsFile
- * @param monitor
- * @param project
- * @throws CoreException
- */
- protected static void backupFile(IFile settingsFile, IProgressMonitor monitor, IProject project) throws CoreException {
- // Make a back-up of the settings file
- String newName = settingsFile.getName() + "_12backup"; //$NON-NLS-1$
- IContainer destFolder = (IContainer)project;
- IFile backupFile = destFolder.getFile(new Path(newName));
- if (backupFile.exists()) {
- Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
- boolean shouldUpdate = MessageDialog.openQuestion(shell,
- ManagedBuilderUIMessages.getResourceString("ManagedBuildConvert.12x.warning.title"), //$NON-NLS-1$
- ManagedBuilderUIMessages.getFormattedString("ManagedBuildConvert.12x.warning.message", project.getName())); //$NON-NLS-1$
- if (shouldUpdate) {
- backupFile.delete(true, monitor);
- } else {
- monitor.setCanceled(true);
- throw new OperationCanceledException(ManagedBuilderUIMessages.getFormattedString("ManagedBuildConvert.12x.cancelled.message", project.getName())); //$NON-NLS-1$
- }
- }
- settingsFile.copy(backupFile.getFullPath(), true, monitor);
- }
-
- protected static void convertConfiguration(ITarget newTarget, ITarget newParent, Element oldConfig, IProgressMonitor monitor) {
- IConfiguration newParentConfig = null;
- IConfiguration newConfig = null;
- boolean cygwin = false;
- boolean debug = false;
- int type = -1;
-
- // Figure out what the original parent of the config is
- String parentId = oldConfig.getAttribute(IConfiguration.PARENT);
- StringTokenizer idTokens = new StringTokenizer(parentId, ID_SEPARATOR);
- while (idTokens.hasMoreTokens()) {
- String id = idTokens.nextToken();
- if (id.equalsIgnoreCase(ID_CYGWIN)) {
- cygwin = true;
- } else if(id.equalsIgnoreCase(ID_EXEC)) {
- type = TYPE_EXE;
- } else if(id.equalsIgnoreCase(ID_SHARED)) {
- type = TYPE_SHARED;
- } else if (id.equalsIgnoreCase(ID_STATIC)) {
- type = TYPE_STATIC;
- } else if (id.equalsIgnoreCase(ID_DEBUG)) {
- debug = true;
- }
- }
- String defId = NEW_CONFIG_ROOT + ID_SEPARATOR;
- if (cygwin) defId += ID_CYGWIN + ID_SEPARATOR;
- switch (type) {
- case TYPE_EXE:
- defId += ID_EXE;
- break;
- case TYPE_SHARED :
- defId += ID_SHARED;
- break;
- case TYPE_STATIC :
- defId += ID_STATIC;
- break;
- }
- defId += ID_SEPARATOR + (debug ? "debug" : "release"); //$NON-NLS-1$ //$NON-NLS-2$
- newParentConfig = newParent.getConfiguration(defId);
- if (newParentConfig == null) {
- // Create a default gnu exe release or debug
- }
- // Generate a random number for the new config id
- Random rand = new Random();
- rand.setSeed(System.currentTimeMillis());
- int randomElement = rand.nextInt();
- if (randomElement < 0) {
- randomElement *= -1;
- }
- // Create the new configuration
- newConfig = newTarget.createConfiguration(newParentConfig, defId + ID_SEPARATOR + randomElement);
-
- // Convert the tool references
- NodeList toolRefNodes = oldConfig.getElementsByTagName(IConfiguration.TOOLREF_ELEMENT_NAME);
- for (int refIndex = 0; refIndex < toolRefNodes.getLength(); ++refIndex) {
- convertToolRef(newConfig, (Element) toolRefNodes.item(refIndex), monitor);
- }
- monitor.worked(1);
- }
-
- protected static void convertOptionRef(IConfiguration newConfig, ITool newTool, Element optRef) {
- String optId = optRef.getAttribute(IOption.ID);
- if (optId == null) return;
- String[] idTokens = optId.split("\\."); //$NON-NLS-1$
-
- // New ID will be in for gnu.[compiler|link|lib].[c|c++|both].option.{1.2_component}
- Vector newIdVector = new Vector(idTokens.length + 2);
-
- // We can ignore the first element of the old IDs since it is just [cygwin|linux|solaris]
- for (int index = 1; index < idTokens.length; ++index) {
- newIdVector.add(idTokens[index]);
- }
-
- // In the case of some Cygwin C++ tools, the old ID will be missing gnu
- if (!((String)newIdVector.firstElement()).equals(ID_GNU)) {
- newIdVector.add(0, ID_GNU);
- }
-
- // In some old IDs the language specifier is missing for librarian and C++ options
- String langToken = (String)newIdVector.get(1);
- if(!langToken.equals(TOOL_LANG_C)) {
- // In the case of the librarian the language must b set to both
- if (langToken.equals(TOOL_NAME_LIB) || langToken.equals(TOOL_NAME_AR)) {
- newIdVector.add(1, TOOL_LANG_BOTH);
- } else {
- newIdVector.add(1, TOOL_LANG_CPP);
- }
- }
-
- // Standardize the next token to compiler, link, or lib
- String toolToken = (String)newIdVector.get(2);
- if (toolToken.equals(ID_PREPROC)) {
- // Some compiler preprocessor options are missing this
- newIdVector.add(2, TOOL_NAME_COMPILER);
- } else if (toolToken.equals(TOOL_NAME_LINKER) || toolToken.equals(TOOL_NAME_SOLINK)) {
- // Some linker options have linker or solink as the toolname
- newIdVector.remove(2);
- newIdVector.add(2, TOOL_NAME_LINK);
- } else if (toolToken.equals(TOOL_NAME_AR)) {
- // The cygwin librarian uses ar
- newIdVector.remove(2);
- newIdVector.add(2, TOOL_NAME_LIB);
- }
-
- // Add in the option tag
- String optionToken = (String)newIdVector.get(3);
- if (optionToken.equals(ID_OPTIONS)) {
- // Some old-style options had "options" in the id
- newIdVector.remove(3);
- }
- newIdVector.add(3, ID_OPTION);
-
- // Convert any lingering "incpaths" to "include.paths"
- String badToken = (String) newIdVector.lastElement();
- if (badToken.equals(ID_INCPATHS)) {
- newIdVector.addElement(ID_INCLUDE);
- newIdVector.addElement(ID_PATHS);
- }
-
- // Edit out the "general" or "dirs" categories that may be in some older IDs
- int generalIndex = newIdVector.indexOf(ID_GENERAL);
- if (generalIndex != -1) {
- newIdVector.remove(generalIndex);
- }
- int dirIndex = newIdVector.indexOf(ID_DIRS);
- if (dirIndex != -1) {
- newIdVector.remove(dirIndex);
- }
-
- // Construct the new ID
- String newOptionId = new String();
- for (int rebuildIndex = 0; rebuildIndex < newIdVector.size(); ++ rebuildIndex) {
- String token = (String) newIdVector.get(rebuildIndex);
- newOptionId += token;
- if (rebuildIndex < newIdVector.size() - 1) {
- newOptionId += ID_SEPARATOR;
- }
- }
-
- // Get the option from the new tool
- IOption newOpt = newTool.getOptionById(newOptionId);
- if (newOpt == null) {
- // TODO flag warning condition to user
- return;
- }
- try {
- switch (newOpt.getValueType()) {
- case IOption.BOOLEAN:
- Boolean bool = new Boolean(optRef.getAttribute(IOption.DEFAULT_VALUE));
- newConfig.setOption(newOpt, bool.booleanValue());
- break;
- case IOption.STRING:
- case IOption.ENUMERATED:
- // This is going to be the human readable form of the enumerated value
- String name = (String) optRef.getAttribute(IOption.DEFAULT_VALUE);
- // Convert it to the ID
- String idValue = newOpt.getEnumeratedId(name);
- newConfig.setOption(newOpt, idValue != null ? idValue : name);
- break;
- case IOption.STRING_LIST:
- case IOption.INCLUDE_PATH:
- case IOption.PREPROCESSOR_SYMBOLS:
- case IOption.LIBRARIES:
- case IOption.OBJECTS:
- Vector values = new Vector();
- NodeList nodes = optRef.getElementsByTagName(IOption.LIST_VALUE);
- for (int i = 0; i < nodes.getLength(); ++i) {
- Node node = nodes.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- Boolean isBuiltIn = new Boolean(((Element)node).getAttribute(IOption.LIST_ITEM_BUILTIN));
- if (!isBuiltIn.booleanValue()) {
- values.add(((Element)node).getAttribute(IOption.LIST_ITEM_VALUE));
- }
- }
- }
- newConfig.setOption(newOpt, (String[])values.toArray(new String[values.size()]));
- break;
- }
- } catch (BuildException e) {
- // TODO flag error to user
- return;
- }
-
- }
- protected static ITarget convertTarget(IProject project, Element oldTarget, IProgressMonitor monitor) {
- // What we want to create
- ITarget newTarget = null;
- ITarget newParent = null;
- // The type of target we are converting from/to
- int type = -1;
- // Use the Cygwin or generic target form
- boolean posix = false;
-
- // Get the parent
- String id = oldTarget.getAttribute(ITarget.PARENT);
-
- // Figure out the new target definition to use for that type
- StringTokenizer idTokens = new StringTokenizer(id, ID_SEPARATOR);
- while (idTokens.hasMoreTokens()) {
- String token = idTokens.nextToken();
- if (token.equals(ID_LINUX) || token.equals(ID_SOLARIS)) {
- posix = true;
- } else if (token.equalsIgnoreCase(ID_EXEC)){
- type = TYPE_EXE;
- } else if (token.equalsIgnoreCase(ID_SHARED)){
- type = TYPE_SHARED;
- } else if (token.equalsIgnoreCase(ID_SHARED)){
- type = TYPE_SHARED;
- }
- }
- // Create a target based on the new target type
- String defID = (posix ? NEW_POSIX_TARGET_ROOT : NEW_CYGWIN_TARGET_ROOT) + ID_SEPARATOR;
- switch (type) {
- case TYPE_EXE :
- defID += ID_EXE;
- break;
- case TYPE_SHARED :
- defID += ID_SHARED;
- break;
- case TYPE_STATIC :
- defID += ID_STATIC;
- break;
- }
-
- // Get the new target definitions we need for the conversion
- newParent = ManagedBuildManager.getTarget(project, defID);
- if (newParent == null) {
- // Return null and let the caller deal with the error reporting
- return null;
- }
-
- try {
- // Create a new target based on the new parent
- newTarget = ManagedBuildManager.createTarget(project, newParent);
- newTarget.setArtifactName(oldTarget.getAttribute(ITarget.ARTIFACT_NAME));
-
- // Create new configurations
- NodeList configNodes = oldTarget.getElementsByTagName(IConfiguration.CONFIGURATION_ELEMENT_NAME);
- for (int configIndex = 0; configIndex < configNodes.getLength(); ++configIndex) {
- convertConfiguration(newTarget, newParent, (Element) configNodes.item(configIndex), monitor);
- }
- } catch (BuildException e) {
- // Probably just a mismatch between option value and option
- }
-
- monitor.worked(1);
- return newTarget;
- }
-
- protected static void convertToolRef(IConfiguration newConfig, Element oldToolRef, IProgressMonitor monitor) {
- String oldToolId = oldToolRef.getAttribute(IToolReference.ID);
- // All known tools have id NEW_TOOL_ROOT.[c|cpp].[compiler|linker|archiver]
- String newToolId = NEW_TOOL_ROOT;
- boolean cppFlag = true;
- int toolType = -1;
-
- // Figure out what kind of tool the ref pointed to
- StringTokenizer idTokens = new StringTokenizer(oldToolId, ID_SEPARATOR);
- while (idTokens.hasMoreTokens()) {
- String token = idTokens.nextToken();
- if(token.equals(TOOL_LANG_C)) {
- cppFlag = false;
- } else if (token.equalsIgnoreCase(TOOL_NAME_COMPILER)) {
- toolType = TOOL_TYPE_COMPILER;
- } else if (token.equalsIgnoreCase(TOOL_NAME_AR)) {
- toolType = TOOL_TYPE_ARCHIVER;
- } else if (token.equalsIgnoreCase(TOOL_NAME_LIB)) {
- toolType = TOOL_TYPE_ARCHIVER;
- } else if (token.equalsIgnoreCase(TOOL_NAME_LINK)) {
- toolType = TOOL_TYPE_LINKER;
- } else if (token.equalsIgnoreCase(TOOL_NAME_SOLINK)) {
- toolType = TOOL_TYPE_LINKER;
- }
- }
-
- // Now complete the new tool id
- newToolId += ID_SEPARATOR + (cppFlag ? "cpp" : "c") + ID_SEPARATOR; //$NON-NLS-1$ //$NON-NLS-2$
- switch (toolType) {
- case TOOL_TYPE_COMPILER:
- newToolId += TOOL_NAME_COMPILER;
- break;
- case TOOL_TYPE_LINKER:
- newToolId += TOOL_NAME_LINKER;
- break;
- case TOOL_TYPE_ARCHIVER:
- newToolId += TOOL_NAME_ARCHIVER;
- break;
- }
-
- // Get the new tool out of the configuration
- ITool newTool = newConfig.getToolById(newToolId);
- // Check that this is not null
-
- // The ref may or may not contain overridden options
- NodeList optRefs = oldToolRef.getElementsByTagName(ITool.OPTION_REF);
- for (int refIndex = optRefs.getLength() - 1; refIndex >= 0; --refIndex) {
- convertOptionRef(newConfig, newTool, (Element) optRefs.item(refIndex));
- }
- monitor.worked(1);
- }
-
- /**
- * @param monitor the monitor to allow users to cancel the long-running operation
- * @param project the <code>IProject</code> that needs to be upgraded
- * @throws CoreException
- */
- protected static void doProjectUpdate(IProgressMonitor monitor, IProject project) throws CoreException {
- String[] projectName = new String[]{project.getName()};
- IFile settingsFile = project.getFile(ManagedBuildManager.SETTINGS_FILE_NAME);
- if (!settingsFile.exists()) {
- monitor.done();
- return;
- }
-
- // Backup the file
- monitor.beginTask(ManagedBuilderUIMessages.getFormattedString("ManagedBuildConvert.12x.monitor.message.backup", projectName), 1); //$NON-NLS-1$
- backupFile(settingsFile, monitor, project);
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
-
- //Now convert each target to the new format
- try {
- // Load the old build file
- InputStream stream = settingsFile.getContents();
- DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document document = parser.parse(stream);
-
- // Clone the target based on the proper target definition
- NodeList targetNodes = document.getElementsByTagName(ITarget.TARGET_ELEMENT_NAME);
- // This is a guess, but typically the project has 1 target, 2 configs, and 6 tool defs
- int listSize = targetNodes.getLength();
- monitor.beginTask(ManagedBuilderUIMessages.getFormattedString("ManagedBuildConvert.12x.monitor.message.project", projectName), listSize * 9); //$NON-NLS-1$
- for (int targIndex = 0; targIndex < listSize; ++targIndex) {
- Element oldTarget = (Element) targetNodes.item(targIndex);
- String oldTargetId = oldTarget.getAttribute(ITarget.ID);
- ITarget newTarget = convertTarget(project, oldTarget, monitor);
-
- // Remove the old target
- if (newTarget != null) {
- info.removeTarget(oldTargetId);
- monitor.worked(9);
- }
- }
- // Upgrade the version
- ((ManagedBuildInfo)info).setVersion(ManagedBuildManager.getBuildInfoVersion().toString());
- } catch (ParserConfigurationException e) {
- ManagedBuilderUIPlugin.log(e);
- } catch (FactoryConfigurationError e) {
- ManagedBuilderUIPlugin.log(e);
- } catch (SAXException e) {
- ManagedBuilderUIPlugin.log(e);
- } catch (IOException e) {
- ManagedBuilderUIPlugin.log(e);
- } finally {
- ManagedBuildManager.saveBuildInfo(project, false);
- monitor.done();
- }
- }
-
- /**
- * Determines which projects in the workspace are still using
- * the settings format defined in CDT 1.2.x.
- *
- * @return an array of <code>IProject</code> that need to have their
- * project settings updated to the CDT 2.0 format
- */
- public static IProject[] getVersion12Projects() {
- IProject[] projects = ManagedBuilderUIPlugin.getWorkspace().getRoot().getProjects();
- Vector result = new Vector();
- for (int index = projects.length - 1; index >=0 ; --index) {
- if (projects[index].isAccessible()) {
- IProjectDescription description;
- try {
- description = projects[index].getDescription();
- } catch (CoreException e) {
- // This can only mean that something really bad has happened
- continue;
- }
- // Make sure it has a managed nature
- if (description == null || !description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) {
- continue;
- }
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(projects[index]);
- if (info != null && info.getVersion()== null) {
- // This is a pre-2.0 file (no version info)
- result.add(projects[index]);
- }
- }
- }
-
- return (IProject[]) result.toArray(new IProject[result.size()]);
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
- */
- public void dispose() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
- */
- public void init(IWorkbenchWindow window) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run(IAction action) {
- // TODO Auto-generated method stub
-
- }
-
- static public void run(boolean fork, IRunnableContext context, final IProject project) {
- try {
- context.run(fork, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- doProjectUpdate(monitor, project);
- }
- };
- ManagedBuilderUIPlugin.getWorkspace().run(runnable, monitor);
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } catch (OperationCanceledException e) {
- throw new InterruptedException(e.getMessage());
- }
- }
- });
- } catch (InterruptedException e) {
- return;
- } catch (InvocationTargetException e) {
- CCorePlugin.log(e); //$NON-NLS-1$
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java
index b40376a977d..68c594dec43 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * Copyright (c) 2002,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,9 +8,12 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.properties;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
@@ -70,6 +71,16 @@ public class BuildOptionComboFieldEditor extends FieldEditor {
selectorData.horizontalSpan = numColumns - 1;
selectorData.grabExcessHorizontalSpace = true;
optionSelector.setLayoutData(selectorData);
+ optionSelector.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ String oldValue = selected;
+ String name = optionSelector.getText();
+ int index = optionSelector.getSelectionIndex();
+ selected = index == -1 ? new String() : optionSelector.getItem(index);
+ setPresentsDefaultValue(false);
+ fireValueChanged(VALUE, oldValue, selected);
+ }
+ });
}
/* (non-Javadoc)
@@ -101,7 +112,7 @@ public class BuildOptionComboFieldEditor extends FieldEditor {
protected void doStore() {
// Save the selected item in the store
int index = optionSelector.getSelectionIndex();
- String selected = index == -1 ? new String() : optionSelector.getItem(index);
+ selected = index == -1 ? new String() : optionSelector.getItem(index);
getPreferenceStore().setValue(getPreferenceName(), selected);
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java
index 2603c2abb0b..3d5f40eb75f 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
/**********************************************************************
- * Copyright (c) 2003,2004 IBM Rational Software Corporation and others.
+ * Copyright (c) 2003,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,13 +8,19 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.properties;
-import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collection;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditor;
@@ -24,15 +28,23 @@ import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.swt.graphics.Point;
public class BuildOptionSettingsPage extends BuildSettingsPage {
- private ArrayList fieldsList = new ArrayList();
+ private Map fieldsMap = new HashMap();
private IOptionCategory category;
+ private boolean isItResourceConfigPage;
- BuildOptionSettingsPage(IConfiguration configuration, IOptionCategory category) {
+ public BuildOptionSettingsPage(IConfiguration configuration, IOptionCategory category) {
// Cache the configuration and option category this page is created for
super(configuration);
this.category = category;
+ isItResourceConfigPage = false;
}
+ public BuildOptionSettingsPage(IResourceConfiguration resConfig, IOptionCategory category) {
+ // Cache the configuration and option category this page is created for
+ super(resConfig);
+ this.category = category;
+ isItResourceConfigPage = true;
+ }
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferencePage#computeSize()
*/
@@ -48,60 +60,70 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
super.createFieldEditors();
// Iterate over the options in the category and create a field editor
// for each
- IOption[] options = category.getOptions(configuration);
+ Object[][] options;
+ if ( isItResourceConfigPage ) {
+ options = category.getOptions(resConfig);
+ } else {
+ options = category.getOptions(configuration);
+ }
+
for (int index = 0; index < options.length; ++index) {
// Get the option
- IOption opt = options[index];
- // Figure out which type the option is and add a proper field
- // editor for it
- switch (opt.getValueType()) {
- case IOption.STRING :
- StringFieldEditor stringField = new StringFieldEditor(opt
- .getId(), opt.getName(), getFieldEditorParent());
- addField(stringField);
- fieldsList.add(stringField);
- break;
- case IOption.BOOLEAN :
- BooleanFieldEditor booleanField = new BooleanFieldEditor(
- opt.getId(), opt.getName(), getFieldEditorParent());
- addField(booleanField);
- fieldsList.add(booleanField);
- break;
- case IOption.ENUMERATED :
- String selId;
- String sel;
- try {
- selId = opt.getSelectedEnum();
- sel = opt.getEnumName(selId);
- } catch (BuildException e) {
- // If we get this exception, then the option type is
- // wrong
+ ITool tool = (ITool)options[index][0];
+ if (tool == null) break; // The array may not be full
+ IOption opt = (IOption)options[index][1];
+ try {
+ // Figure out which type the option is and add a proper field
+ // editor for it
+ switch (opt.getValueType()) {
+ case IOption.STRING :
+ StringFieldEditor stringField = new StringFieldEditor(
+ opt.getId(), opt.getName(), getFieldEditorParent());
+ addField(stringField);
+ fieldsMap.put(opt.getId(), stringField);
+ break;
+ case IOption.BOOLEAN :
+ BooleanFieldEditor booleanField = new BooleanFieldEditor(
+ opt.getId(), opt.getName(), getFieldEditorParent());
+ addField(booleanField);
+ fieldsMap.put(opt.getId(),booleanField);
+ break;
+ case IOption.ENUMERATED :
+ String selId;
+ String sel;
+ try {
+ selId = opt.getSelectedEnum();
+ sel = opt.getEnumName(selId);
+ } catch (BuildException e) {
+ // If we get this exception, then the option type is
+ // wrong
+ break;
+ }
+ BuildOptionComboFieldEditor comboField = new BuildOptionComboFieldEditor(
+ opt.getId(), opt.getName(), opt
+ .getApplicableValues(), sel,
+ getFieldEditorParent());
+ addField(comboField);
+ fieldsMap.put(opt.getId(), comboField);
break;
- }
- BuildOptionComboFieldEditor comboField = new BuildOptionComboFieldEditor(
- opt.getId(), opt.getName(), opt
- .getApplicableValues(), sel,
- getFieldEditorParent());
- addField(comboField);
- fieldsList.add(comboField);
- break;
- case IOption.INCLUDE_PATH :
- case IOption.STRING_LIST :
- case IOption.PREPROCESSOR_SYMBOLS :
- case IOption.LIBRARIES :
- case IOption.OBJECTS :
- FileListControlFieldEditor listField =
- new FileListControlFieldEditor(
- opt.getId(),
- opt.getName(),
- getFieldEditorParent(),
- opt.getBrowseType());
- addField(listField);
- fieldsList.add(listField);
- break;
- default :
- break;
- }
+ case IOption.INCLUDE_PATH :
+ case IOption.STRING_LIST :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ FileListControlFieldEditor listField =
+ new FileListControlFieldEditor(
+ opt.getId(),
+ opt.getName(),
+ getFieldEditorParent(),
+ opt.getBrowseType());
+ addField(listField);
+ fieldsMap.put(opt.getId(), listField);
+ break;
+ default :
+ break;
+ }
+ } catch (BuildException e) {}
}
}
@@ -126,46 +148,92 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
// Write the field editor contents out to the preference store
boolean ok = super.performOk();
// Write the preference store values back to the build model
- IOption[] options = category.getOptions(configuration);
+
+ Object[][] options;
+ if (isItResourceConfigPage){
+ options = category.getOptions(resConfig);
+ } else {
+ options = category.getOptions(configuration);
+ }
+
for (int i = 0; i < options.length; i++) {
- IOption option = options[i];
-
- // Transfer value from preference store to options
- switch (option.getValueType()) {
- case IOption.BOOLEAN :
- boolean boolVal = getPreferenceStore().getBoolean(
- option.getId());
- ManagedBuildManager.setOption(configuration, option,
- boolVal);
- break;
- case IOption.ENUMERATED :
- String enumVal = getPreferenceStore().getString(
- option.getId());
- String enumId = option.getEnumeratedId(enumVal);
- ManagedBuildManager.setOption(configuration, option,
- (enumId.length() > 0) ? enumId : enumVal);
- break;
- case IOption.STRING :
- String strVal = getPreferenceStore().getString(
- option.getId());
- ManagedBuildManager
- .setOption(configuration, option, strVal);
- break;
- case IOption.STRING_LIST :
- case IOption.INCLUDE_PATH :
- case IOption.PREPROCESSOR_SYMBOLS :
- case IOption.LIBRARIES :
- case IOption.OBJECTS :
- String listStr = getPreferenceStore().getString(
- option.getId());
- String[] listVal = BuildToolsSettingsStore
- .parseString(listStr);
- ManagedBuildManager.setOption(configuration, option,
- listVal);
- break;
- default :
- break;
- }
+ ITool tool = (ITool)options[i][0];
+ if (tool == null) break; // The array may not be full
+ IOption option = (IOption)options[i][1];
+ try {
+ // Transfer value from preference store to options
+ IOption setOption;
+ switch (option.getValueType()) {
+ case IOption.BOOLEAN :
+ boolean boolVal = getToolSettingsPreferenceStore().getBoolean(option.getId());
+ if(isItResourceConfigPage) {
+ setOption = ManagedBuildManager.setOption(resConfig, tool, option, boolVal);
+ } else {
+ setOption = ManagedBuildManager.setOption(configuration, tool, option, boolVal);
+ }
+ // Reset the preference store since the Id may have changed
+ if (setOption != option) {
+ getToolSettingsPreferenceStore().setValue(setOption.getId(), boolVal);
+ FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
+ fe.setPreferenceName(setOption.getId());
+ }
+ break;
+ case IOption.ENUMERATED :
+ String enumVal = getToolSettingsPreferenceStore().getString(option.getId());
+ String enumId = option.getEnumeratedId(enumVal);
+ if(isItResourceConfigPage) {
+ setOption = ManagedBuildManager.setOption(resConfig, tool, option,
+ (enumId != null && enumId.length() > 0) ? enumId : enumVal);
+ } else {
+ setOption = ManagedBuildManager.setOption(configuration, tool, option,
+ (enumId != null && enumId.length() > 0) ? enumId : enumVal);
+ }
+ // Reset the preference store since the Id may have changed
+ if (setOption != option) {
+ getToolSettingsPreferenceStore().setValue(setOption.getId(), enumVal);
+ FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
+ fe.setPreferenceName(setOption.getId());
+ }
+ break;
+ case IOption.STRING :
+ String strVal = getToolSettingsPreferenceStore().getString(option.getId());
+ if(isItResourceConfigPage){
+ setOption = ManagedBuildManager.setOption(resConfig, tool, option, strVal);
+ } else {
+ setOption = ManagedBuildManager.setOption(configuration, tool, option, strVal);
+ }
+
+ // Reset the preference store since the Id may have changed
+ if (setOption != option) {
+ getToolSettingsPreferenceStore().setValue(setOption.getId(), strVal);
+ FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
+ fe.setPreferenceName(setOption.getId());
+ }
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ String listStr = getToolSettingsPreferenceStore().getString(option.getId());
+ String[] listVal = BuildToolsSettingsStore.parseString(listStr);
+ if( isItResourceConfigPage){
+ setOption = ManagedBuildManager.setOption(resConfig, tool, option, listVal);
+ }else {
+ setOption = ManagedBuildManager.setOption(configuration, tool, option, listVal);
+ }
+
+ // Reset the preference store since the Id may have changed
+ if (setOption != option) {
+ getToolSettingsPreferenceStore().setValue(setOption.getId(), listStr);
+ FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
+ fe.setPreferenceName(setOption.getId());
+ }
+ break;
+ default :
+ break;
+ }
+ } catch (BuildException e) {}
}
return ok;
}
@@ -174,9 +242,13 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
* Update field editors in this page when the page is loaded.
*/
public void updateFields() {
- for (int i = 0; i < fieldsList.size(); i++) {
- FieldEditor editor = (FieldEditor) fieldsList.get(i);
- editor.loadDefault();
+ Collection fieldsList = fieldsMap.values();
+ Iterator iter = fieldsList.iterator();
+ while (iter.hasNext()) {
+ FieldEditor editor = (FieldEditor) iter.next();
+ // TODO: Why was loadDefault called before load? It results in String fields
+ // setting the "dirty" flag
+ //editor.loadDefault();
editor.load();
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java
index bcecbe7b6e7..9e4dfcff147 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java
@@ -1,5 +1,3 @@
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
/**********************************************************************
* Copyright (c) 2002,2004 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
@@ -10,43 +8,36 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
* Contributors:
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.properties;
-import java.util.ArrayList;
-import java.util.HashMap;
+import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Random;
import java.util.Set;
import java.util.SortedMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
-import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
+import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferencePageContainer;
import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
@@ -59,137 +50,104 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
import org.eclipse.ui.dialogs.PropertyPage;
import org.eclipse.ui.help.WorkbenchHelp;
-public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropertyPage, IPreferencePageContainer {
+public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropertyPage,
+ IPreferencePageContainer, ICOptionContainer {
/*
* String constants
*/
private static final String PREFIX = "BuildPropertyPage"; //$NON-NLS-1$
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
- private static final String NAME_LABEL = LABEL + ".NameText"; //$NON-NLS-1$
- private static final String BUILD_TOOLS_LABEL = LABEL + ".BuildToolTree"; //$NON-NLS-1$
private static final String PLATFORM_LABEL = LABEL + ".Platform"; //$NON-NLS-1$
private static final String CONFIG_LABEL = LABEL + ".Configuration"; //$NON-NLS-1$
private static final String ALL_CONFS = PREFIX + ".selection.configuration.all"; //$NON-NLS-1$
private static final String ACTIVE_LABEL = LABEL + ".Active"; //$NON-NLS-1$
private static final String SETTINGS_LABEL = LABEL + ".Settings"; //$NON-NLS-1$
- private static final String TREE_LABEL = LABEL + ".ToolTree"; //$NON-NLS-1$
- private static final String OPTIONS_LABEL = LABEL + ".ToolOptions"; //$NON-NLS-1$
private static final String ADD_CONF = LABEL + ".AddConfButton"; //$NON-NLS-1$
private static final String TIP = PREFIX + ".tip"; //$NON-NLS-1$
private static final String PLAT_TIP = TIP + ".platform"; //$NON-NLS-1$
private static final String CONF_TIP = TIP + ".config"; //$NON-NLS-1$
private static final String ADD_TIP = TIP + ".addconf"; //$NON-NLS-1$
private static final String MANAGE_TITLE = PREFIX + ".manage.title"; //$NON-NLS-1$
- private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { 20, 30 };
private static final String ID_SEPARATOR = "."; //$NON-NLS-1$
+ private static final String MSG_CLOSEDPROJECT = "MngMakeProjectPropertyPage.closedproject"; //$NON-NLS-1$
/*
* Dialog widgets
*/
- private Combo targetSelector;
+ private Combo projectTypeSelector;
private Combo configSelector;
private Button manageConfigs;
- private TreeViewer optionList;
- private SashForm sashForm;
- private Group sashGroup;
- private Composite settingsPageContainer;
- private ScrolledComposite containerSC;
/*
* Bookeeping variables
*/
- private ITarget [] targets;
- private ITarget selectedTarget;
- private IConfiguration [] configurations;
+ private IProjectType[] projectTypes;
+ private IProjectType selectedProjectType;
+ private IConfiguration[] configurations;
private IConfiguration selectedConfiguration;
- private BuildSettingsPage currentSettingsPage;
- private Map configToPageListMap;
- private BuildToolsSettingsStore settingsStore;
- private Map settingsStoreMap;
- private IOptionCategory selectedCategory;
private Point lastShellSize;
- private ITool selectedTool;
-
- /**
- * The minimum page size; 200 by 200 by default.
- *
- * @see #setMinimumPageSize
- */
- private Point minimumPageSize = new Point(200, 200);
- private ToolListContentProvider provider;
-
- /**
- * Layout for the page container.
- *
- */
- private class PageLayout extends Layout {
- public void layout(Composite composite, boolean force) {
- Rectangle rect = composite.getClientArea();
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++) {
- children[i].setSize(rect.width, rect.height);
- }
- }
- public Point computeSize(Composite composite, int wHint, int hHint, boolean force) {
- if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
- return new Point(wHint, hHint);
- }
- int x = minimumPageSize.x;
- int y = minimumPageSize.y;
-
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++) {
- Point size = children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
- x = Math.max(x, size.x);
- y = Math.max(y, size.y);
- }
- if (wHint != SWT.DEFAULT) {
- x = wHint;
- }
- if (hHint != SWT.DEFAULT) {
- y = hHint;
- }
- return new Point(x, y);
- }
- }
+ protected ManagedBuildOptionBlock fOptionBlock;
+ protected boolean displayedConfig = false;
/**
* Default constructor
*/
public BuildPropertyPage() {
- configToPageListMap = new HashMap();
+ super();
}
+ public void setContainer(IPreferencePageContainer preferencePageContainer) {
+ super.setContainer(preferencePageContainer);
+ if (fOptionBlock == null) {
+ fOptionBlock = new ManagedBuildOptionBlock(this);
+ }
+ }
+
protected Control createContents(Composite parent) {
// Create the container we return to the property page editor
Composite composite = new Composite(parent, SWT.NULL);
composite.setFont(parent.getFont());
- composite.setLayout(new GridLayout(1, true));
+ GridLayout compositeLayout = new GridLayout();
+ compositeLayout.numColumns = 1;
+ compositeLayout.marginHeight = 0;
+ compositeLayout.marginWidth = 0;
+ composite.setLayout( compositeLayout );
+
+ IProject project = getProject();
+ if (!project.isOpen()) {
+ contentForClosedProject(composite);
+ } else {
+ contentForCProject(composite);
+ }
+
+ return composite;
+ }
+
+ private void contentForCProject(Composite parent) {
GridData gd;
// Initialize the key data
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
if (info.getVersion() == null) {
// Display a message page instead of the properties control
- final Label invalidInfo = new Label(composite, SWT.LEFT);
- invalidInfo.setFont(composite.getFont());
+ final Label invalidInfo = new Label(parent, SWT.LEFT);
+ invalidInfo.setFont(parent.getFont());
invalidInfo.setText(ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.error.version_low")); //$NON-NLS-1$
invalidInfo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_CENTER, true, true));
- return composite;
+ return;
}
- targets = ManagedBuildManager.getTargets(getProject());
- ITarget defaultTarget = info.getDefaultTarget();
-
+ projectTypes = ManagedBuildManager.getDefinedProjectTypes();
+ IProjectType defaultProjectType = info.getManagedProject().getProjectType();
// Add a config selection area
- Group configGroup = ControlFactory.createGroup(composite, ManagedBuilderUIMessages.getResourceString(ACTIVE_LABEL), 1);
+ Group configGroup = ControlFactory.createGroup(parent, ManagedBuilderUIMessages.getResourceString(ACTIVE_LABEL), 1);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.grabExcessHorizontalSpace = true;
configGroup.setLayoutData(gd);
@@ -200,13 +158,15 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
configGroup.setLayout(form);
Label platformLabel = ControlFactory.createLabel(configGroup, ManagedBuilderUIMessages.getResourceString(PLATFORM_LABEL));
- targetSelector = ControlFactory.createSelectCombo(configGroup, getPlatformNames(), defaultTarget.getName());
- targetSelector.addListener(SWT.Selection, new Listener () {
+ projectTypeSelector = ControlFactory.createSelectCombo(configGroup, getPlatformNames(), defaultProjectType.getName());
+ // Note: Changing the project type is not currently handled, so this widget is disabled
+ projectTypeSelector.setEnabled(false);
+ projectTypeSelector.addListener(SWT.Selection, new Listener () {
public void handleEvent(Event e) {
- handleTargetSelection();
+ handleProjectTypeSelection();
}
});
- targetSelector.setToolTipText(ManagedBuilderUIMessages.getResourceString(PLAT_TIP));
+ projectTypeSelector.setToolTipText(ManagedBuilderUIMessages.getResourceString(PLAT_TIP));
Label configLabel = ControlFactory.createLabel(configGroup, ManagedBuilderUIMessages.getResourceString(CONFIG_LABEL));
configSelector = new Combo(configGroup, SWT.READ_ONLY|SWT.DROP_DOWN);
configSelector.addListener(SWT.Selection, new Listener () {
@@ -225,7 +185,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
// Now do the form layout for the widgets
FormData fd = new FormData();
// Anchor the labels in the centre of their respective combos
- fd.top = new FormAttachment(targetSelector, 0, SWT.CENTER);
+ fd.top = new FormAttachment(projectTypeSelector, 0, SWT.CENTER);
platformLabel.setLayoutData(fd);
fd = new FormData();
fd.top = new FormAttachment(configSelector, 0, SWT.CENTER);
@@ -234,7 +194,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
fd = new FormData();
fd.left = new FormAttachment(configSelector, 0, SWT.LEFT);
fd.right = new FormAttachment(100, 0);
- targetSelector.setLayoutData(fd);
+ projectTypeSelector.setLayoutData(fd);
// Anchor button right to combo and left to group
fd = new FormData();
fd.top = new FormAttachment(configSelector, 0, SWT.CENTER);
@@ -247,201 +207,105 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
fd.top = new FormAttachment(55,0);
fd.right = new FormAttachment(manageConfigs, -5 , SWT.LEFT);
configSelector.setLayoutData(fd);
-
- // Create the sash form
- sashGroup = ControlFactory.createGroup(composite, ManagedBuilderUIMessages.getResourceString(SETTINGS_LABEL), 1);
- sashGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
- sashForm = new SashForm(sashGroup, SWT.NONE);
- sashForm.setOrientation(SWT.HORIZONTAL);
- sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginHeight = 5;
- layout.marginWidth = 5;
- sashForm.setLayout(layout);
- createSelectionArea(sashForm);
- createEditArea(sashForm);
- initializeSashForm();
+ // Create the Tools Settings, Build Settings, ... Tabbed pane
+ Group tabGroup = ControlFactory.createGroup(parent, ManagedBuilderUIMessages.getResourceString(SETTINGS_LABEL), 1);
+ gd = new GridData(GridData.FILL_BOTH);
+ tabGroup.setLayoutData(gd);
+ fOptionBlock.createContents(tabGroup, getElement());
// Do not call this until the widgets are constructed
- handleTargetSelection();
+ handleProjectTypeSelection();
- WorkbenchHelp.setHelp(composite, ManagedBuilderHelpContextIds.MAN_PROJ_BUILD_PROP);
- return composite;
+ WorkbenchHelp.setHelp(parent, ManagedBuilderHelpContextIds.MAN_PROJ_BUILD_PROP);
}
-
- /* (non-Javadoc)
- * Add the tabs relevant to the project to edit area tab folder.
- */
- protected void createEditArea(Composite parent) {
- containerSC = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
- containerSC.setExpandHorizontal(true);
- containerSC.setExpandVertical(true);
-
- // Add a container for the build settings page
- settingsPageContainer = new Composite(containerSC, SWT.NULL);
- settingsPageContainer.setLayout(new PageLayout());
- containerSC.setContent(settingsPageContainer);
- containerSC.setMinSize(settingsPageContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT));
- settingsPageContainer.layout();
- }
-
- protected void createSelectionArea (Composite parent) {
- // Create a label and list viewer
- Composite composite = ControlFactory.createComposite(parent, 1);
- optionList = new TreeViewer(composite, SWT.SINGLE|SWT.H_SCROLL|SWT.V_SCROLL|SWT.BORDER);
- optionList.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- handleOptionSelection();
- }
- });
- optionList.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
- optionList.setLabelProvider(new ToolListLabelProvider());
+ private void contentForClosedProject(Composite parent) {
+ Label label = new Label(parent, SWT.LEFT);
+ label.setText(ManagedBuilderUIMessages.getResourceString(MSG_CLOSEDPROJECT));
+ label.setFont(parent.getFont());
+
+ noDefaultAndApplyButton();
}
- /* (non-Javadoc)
- * Method displayOptionsForTool.
- * @param toolReference
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.IPreferencePage#performOk()
*/
- private void displayOptionsForCategory(IOptionCategory category) {
- // Do nothing if the selected category is is unchanged
- if (category == selectedCategory) {
- return;
- }
- selectedTool = null;
- selectedCategory = category;
-
- // Cache the current build setting page
- BuildSettingsPage oldPage = currentSettingsPage;
- currentSettingsPage = null;
-
- // Create a new settings page if necessary
- List pages = getPagesForConfig();
- ListIterator iter = pages.listIterator();
- while (iter.hasNext()) {
- BuildSettingsPage page = (BuildSettingsPage) iter.next();
- if (page instanceof BuildOptionSettingsPage &&
- ((BuildOptionSettingsPage)page).isForCategory(category)) {
- currentSettingsPage = page;
- break;
- }
- }
- if (currentSettingsPage == null) {
- currentSettingsPage = new BuildOptionSettingsPage(selectedConfiguration, category);
- pages.add(currentSettingsPage);
- currentSettingsPage.setContainer(this);
- if (currentSettingsPage.getControl() == null) {
- currentSettingsPage.createControl(settingsPageContainer);
- }
- }
-
- // Make all the other pages invisible
- Control[] children = settingsPageContainer.getChildren();
- Control currentControl = currentSettingsPage.getControl();
- for (int i = 0; i < children.length; i++) {
- if (children[i] != currentControl)
- children[i].setVisible(false);
- }
- currentSettingsPage.setVisible(true);
-
- // save the last page build options.
- // If the last page is tool page then parse all the options
- // and put it in the appropriate preference store.
- if (oldPage != null){
- if(oldPage instanceof BuildOptionSettingsPage) {
- ((BuildOptionSettingsPage)oldPage).storeSettings();
- }
- else if(oldPage instanceof BuildToolSettingsPage) {
- ((BuildToolSettingsPage)oldPage).storeSettings();
- ((BuildToolSettingsPage)oldPage).parseAllOptions();
+ public boolean performOk() {
+
+ // If the user did not visit this page, then there is nothing to do.
+ if (!displayedConfig) return true;
+
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ fOptionBlock.performApply(monitor);
}
+ };
+ IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
+ try {
+ new ProgressMonitorDialog(getShell()).run(false, true, op);
+ } catch (InvocationTargetException e) {
+ Throwable e1 = e.getTargetException();
+ ManagedBuilderUIPlugin.errorDialog(getShell(), ManagedBuilderUIMessages.getResourceString("ManagedProjectPropertyPage.internalError"),e1.toString(), e1); //$NON-NLS-1$
+ return false;
+ } catch (InterruptedException e) {
+ // cancelled
+ return false;
}
- //update the field editors in the current page
- if(currentSettingsPage instanceof BuildOptionSettingsPage)
- ((BuildOptionSettingsPage)currentSettingsPage).updateFields();
-
- if (oldPage != null)
- oldPage.setVisible(false);
- // Set the size of the scrolled area
- containerSC.setMinSize(currentSettingsPage.computeSize());
- settingsPageContainer.layout();
+ // Write out the build model info
+ ManagedBuildManager.setDefaultConfiguration(getProject(), getSelectedConfiguration());
+ ManagedBuildManager.saveBuildInfo(getProject(), false);
+ return true;
}
- /* (non-Javadoc)
- * @param tool
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
*/
- private void displayOptionsForTool(ITool tool) {
- if (tool == selectedTool) {
- return;
- }
- // Unselect the category
- selectedCategory = null;
- // record that the tool selection has changed
- selectedTool = tool;
-
- // Cache the current build setting page
- BuildSettingsPage oldPage = currentSettingsPage;
- currentSettingsPage = null;
-
- // Create a new page if we need one
- List pages = getPagesForConfig();
- ListIterator iter = pages.listIterator();
- while (iter.hasNext()) {
- BuildSettingsPage page = (BuildSettingsPage) iter.next();
- if (page instanceof BuildToolSettingsPage &&
- ((BuildToolSettingsPage)page).isForTool(tool)) {
- currentSettingsPage = page;
- break;
- }
- }
- if (currentSettingsPage == null) {
- currentSettingsPage = new BuildToolSettingsPage(selectedConfiguration, tool);
- pages.add(currentSettingsPage);
- currentSettingsPage.setContainer(this);
- if (currentSettingsPage.getControl() == null) {
- currentSettingsPage.createControl(settingsPageContainer);
- }
- }
- // Make all the other pages invisible
- Control[] children = settingsPageContainer.getChildren();
- Control currentControl = currentSettingsPage.getControl();
- for (int i = 0; i < children.length; i++) {
- if (children[i] != currentControl)
- children[i].setVisible(false);
- }
-
- // Make the current page visible
- currentSettingsPage.setVisible(true);
-
- // save the last page build options.
- // If the last page is tool page then parse all the options
- // and put it in the appropriate preference store.
- if (oldPage != null){
- if(oldPage instanceof BuildOptionSettingsPage) {
- ((BuildOptionSettingsPage)oldPage).storeSettings();
- }
- else if(oldPage instanceof BuildToolSettingsPage) {
- ((BuildToolSettingsPage)oldPage).storeSettings();
- ((BuildToolSettingsPage)oldPage).parseAllOptions();
- }
+ protected void performDefaults() {
+ fOptionBlock.performDefaults();
+ super.performDefaults();
+ }
+
+ private String [] getPlatformNames() {
+ String [] names = new String[projectTypes.length];
+ for (int index = 0; index < projectTypes.length; ++index) {
+ names[index] = projectTypes[index].getName();
}
- //update the field editor that displays all the build options
- if(currentSettingsPage instanceof BuildToolSettingsPage)
- ((BuildToolSettingsPage)currentSettingsPage).updateAllOptionField();
+ return names;
+ }
- if (oldPage != null)
- oldPage.setVisible(false);
+ /* (non-Javadoc)
+ * @return
+ */
+ public IProjectType getSelectedProjectType() {
+ return selectedProjectType;
+ }
- // Set the size of the scrolled area
- containerSC.setMinSize(currentSettingsPage.computeSize());
- settingsPageContainer.layout();
+ private void populateConfigurations() {
+ // If the config select widget is not there yet, just stop
+ if (configSelector == null) return;
+
+ // Find the configurations defined for the platform
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
+ configurations = info.getManagedProject().getConfigurations();
+ if (configurations.length == 0) return;
+
+ // Clear and replace the contents of the selector widget
+ configSelector.removeAll();
+ configSelector.setItems(getConfigurationNames());
+
+ // Make sure the active configuration is selected
+ IConfiguration defaultConfig = info.getDefaultConfiguration();
+ int index = configSelector.indexOf(defaultConfig.getName());
+ configSelector.select(index == -1 ? 0 : index);
+ handleConfigSelection();
}
/* (non-Javadoc)
- * @return an array of names for the configurations defined for the chosen target
+ * @return an array of names for the configurations defined for the chosen
*/
private String [] getConfigurationNames () {
String [] names = new String[configurations.length /*+ 1*/];
@@ -451,6 +315,17 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
// names[names.length - 1] = ManagedBuilderUIPlugin.getResourceString(ALL_CONFS);
return names;
}
+
+ public void enableConfigSelection (boolean enable) {
+ configSelector.setEnabled(enable);
+ }
+
+ /* (non-Javadoc)
+ * @return
+ */
+ public IConfiguration getSelectedConfiguration() {
+ return selectedConfiguration;
+ }
/* (non-Javadoc)
* @return
@@ -465,71 +340,76 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
}
/* (non-Javadoc)
- * Answers the list of settings pages for the selected configuration
- * @return
+ * @see org.eclipse.jface.preference.IPreferencePageContainer#getPreferenceStore()
*/
- private List getPagesForConfig() {
- // Make sure that something was selected
- if (selectedConfiguration == null) {
- return null;
- }
- List pages = (List) configToPageListMap.get(selectedConfiguration.getId());
- if (pages == null) {
- pages = new ArrayList();
- configToPageListMap.put(selectedConfiguration.getId(), pages);
- }
- return pages;
+ public IPreferenceStore getPreferenceStore()
+ {
+ return fOptionBlock.getPreferenceStore();
}
-
- private String [] getPlatformNames() {
- String [] names = new String[targets.length];
- for (int index = 0; index < targets.length; ++index) {
- names[index] = targets[index].getName();
- }
- return names;
+
+ /* (non-Javadoc)
+ * Return the IPreferenceStore of the Tool Settings block
+ */
+ public IPreferenceStore getToolSettingsPreferenceStore()
+ {
+ return fOptionBlock.getToolSettingsPreferenceStore();
}
/* (non-Javadoc)
- * @see org.eclipse.jface.preference.IPreferencePageContainer#getPreferenceStore()
+ * @see org.eclipse.cdt.ui.dialog.ICOptionContainer.getPreferences()
*/
- public IPreferenceStore getPreferenceStore()
+ public Preferences getPreferences()
{
- return settingsStore;
+ return null;
}
- private IProject getProject() {
+ public IProject getProject() {
Object element= getElement();
if (element != null && element instanceof IProject) {
return (IProject)element;
}
return null;
}
-
- /* (non-Javadoc)
- * @return
- */
- public ITarget getSelectedTarget() {
- return selectedTarget;
+
+ public void updateContainer() {
+ fOptionBlock.update();
+ setValid(fOptionBlock.isValid());
+ setErrorMessage(fOptionBlock.getErrorMessage());
}
- /* (non-Javadoc)
- * @return
- */
- protected IConfiguration getSelectedConfiguration() {
- return selectedConfiguration;
+ public boolean isValid() {
+ updateContainer();
+ return super.isValid();
}
- /* (non-Javadoc)
- * Safe accessor method
- *
- * @return Returns the Map of configurations to preference stores.
+ /**
+ * @see DialogPage#setVisible(boolean)
*/
- protected Map getSettingsStoreMap() {
- if (settingsStoreMap == null) {
- settingsStoreMap = new HashMap();
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ fOptionBlock.setVisible(visible);
+ if (visible) {
+ fOptionBlock.updateValues();
+ displayedConfig = true;
}
- return settingsStoreMap;
}
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferencePageContainer#updateButtons()
+ */
+ public void updateButtons() {
+ }
+ /**
+ * @see org.eclipse.jface.preference.IPreferencePageContainer#updateMessage()
+ */
+ public void updateMessage() {
+ }
+ /**
+ * @see org.eclipse.jface.preference.IPreferencePageContainer#updateTitle()
+ */
+ public void updateTitle() {
+ }
+
/*
* Event Handlers
*/
@@ -537,7 +417,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
// If there is nothing in config selection widget just bail
if (configSelector.getItemCount() == 0) return;
- // Check if the user has selected the "all" configuration
+ // TODO: Check if the user has selected the "all" configuration
int selectionIndex = configSelector.getSelectionIndex();
if (selectionIndex == -1) return;
String configName = configSelector.getItem(selectionIndex);
@@ -546,95 +426,58 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
return;
} else {
// Cache the selected config
- selectedConfiguration = configurations[selectionIndex];
- }
-
- if (provider == null) {
- provider = new ToolListContentProvider();
- optionList.setContentProvider(provider);
- }
- optionList.setInput(selectedConfiguration);
- optionList.expandAll();
-
- // Create (or retrieve) the settings store for the configuration
- BuildToolsSettingsStore store = (BuildToolsSettingsStore) getSettingsStoreMap().get(selectedConfiguration.getId());
- if (store == null) {
- store = new BuildToolsSettingsStore(selectedConfiguration);
- getSettingsStoreMap().put(selectedConfiguration.getId(), store);
- }
- settingsStore = store;
-
- // Select the first tool in the list
- Object[] elements = provider.getElements(selectedConfiguration);
- Object primary = elements.length > 0 ? elements[0] : null;
-
-/* if (primary != null && primary instanceof ITool) {
- // set the tool as primary selection in the tree hence it displays all the build options.
- ITool tool = (ITool)primary;
- IOptionCategory top = tool.getTopOptionCategory();
- IOption[] topOpts = top.getOptions(selectedConfiguration);
- if (topOpts != null && topOpts.length == 0) {
- // Get the children categories and start looking
- IOptionCategory[] children = top.getChildCategories();
- for (int i = 0; i < children.length; i++) {
- IOptionCategory category = children[i];
- IOption[] catOpts = category.getOptions(selectedConfiguration);
- if (catOpts != null && catOpts.length > 0) {
- primary = category;
- break;
- }
- }
+ IConfiguration newConfig = configurations[selectionIndex];
+ if (newConfig != selectedConfiguration) {
+ // If the user has changed values, and is now switching configurations, prompt for saving
+ if (selectedConfiguration != null) {
+ if (fOptionBlock.isDirty()) {
+ Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
+ boolean shouldApply = MessageDialog.openQuestion(shell,
+ ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.changes.save.title"), //$NON-NLS-1$
+ ManagedBuilderUIMessages.getFormattedString("BuildPropertyPage.changes.save.question", //$NON-NLS-1$
+ new String[] {selectedConfiguration.getName(), newConfig.getName()}));
+ if (shouldApply) {
+ if (performOk()) {
+ fOptionBlock.setDirty(false);
+ } else {
+ MessageDialog.openWarning(shell,
+ ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.changes.save.title"), //$NON-NLS-1$
+ ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.changes.save.error")); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ // Set the new selected configuration
+ selectedConfiguration = newConfig;
+ ManagedBuildManager.setSelectedConfiguration(getProject(), selectedConfiguration);
+ // TODO: Set the appropriate error parsers...
+ // TODO: Binary parsers too?
+ fOptionBlock.updateValues();
}
}
-*/
- if (primary != null) {
- optionList.setSelection(new StructuredSelection(primary));
- }
}
// Event handler for the manage configuration button event
private void handleManageConfig () {
- ManageConfigDialog manageDialog = new ManageConfigDialog(getShell(), ManagedBuilderUIMessages.getResourceString(MANAGE_TITLE), selectedTarget);
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
+ ManageConfigDialog manageDialog = new ManageConfigDialog(getShell(), ManagedBuilderUIMessages.getResourceString(MANAGE_TITLE), info.getManagedProject());
if (manageDialog.open() == ManageConfigDialog.OK) {
boolean updateConfigs = false;
- // Get the build output name
- String newBuildOutput = manageDialog.getBuildArtifactName();
- if (!selectedTarget.getArtifactName().equals(newBuildOutput)) {
- selectedTarget.setArtifactName(newBuildOutput);
- }
- String newBuildExt = manageDialog.getBuildArtifaceExtension();
- if (!selectedTarget.getArtifactExtension().equals(newBuildExt)) {
- selectedTarget.setArtifactExtension(newBuildExt);
- }
-
- // Get the new make command
- if (manageDialog.useDefaultMakeCommand()) {
- // This is a cheap assignment to null so do it to be doubly sure
- selectedTarget.resetMakeCommand();
- } else {
- // Parse for command and arguments
- String rawCommand = manageDialog.getMakeCommand();
- String makeCommand = parseMakeCommand(rawCommand);
- selectedTarget.setMakeCommand(makeCommand);
- String makeArguments = parseMakeArgs(rawCommand);
- selectedTarget.setMakeArguments(makeArguments);
- }
-
// Check to see if any configurations have to be deleted
List deletedConfigs = manageDialog.getDeletedConfigIds();
Iterator iter = deletedConfigs.listIterator();
while (iter.hasNext()) {
String id = (String)iter.next();
- // Remove the configurations from the target
- selectedTarget.removeConfiguration(id);
+ // Remove the configurations from the project
+ info.getManagedProject().removeConfiguration(id);
// Remove any settings stores
- getSettingsStoreMap().remove(id);
+ fOptionBlock.removeValues(id);
// Clean up the UI
- configurations = selectedTarget.getConfigurations();
+ configurations = info.getManagedProject().getConfigurations();
configSelector.removeAll();
configSelector.setItems(getConfigurationNames());
configSelector.select(0);
@@ -645,16 +488,11 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
SortedMap newConfigs = manageDialog.getNewConfigs();
Set keys = newConfigs.keySet();
Iterator keyIter = keys.iterator();
- Random r = new Random();
- r.setSeed(System.currentTimeMillis());
while (keyIter.hasNext()) {
String name = (String) keyIter.next();
IConfiguration parent = (IConfiguration) newConfigs.get(name);
if (parent != null) {
- int id = r.nextInt();
- if (id < 0) {
- id *= -1;
- }
+ int id = ManagedBuildManager.getRandomNumber();
// Create ID for the new component based on the parent ID and random component
String newId = parent.getId();
@@ -667,10 +505,16 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
}
}
newId += ID_SEPARATOR + id;
- IConfiguration newConfig = selectedTarget.createConfiguration(parent, newId);
+ IConfiguration newConfig;
+ if (parent.isExtensionElement()) {
+ newConfig = info.getManagedProject().createConfiguration(parent, newId);
+ } else {
+ newConfig = info.getManagedProject().createConfigurationClone(parent, newId);
+ }
newConfig.setName(name);
+ newConfig.setArtifactName(info.getManagedProject().getDefaultArtifactName());
// Update the config lists
- configurations = selectedTarget.getConfigurations();
+ configurations = info.getManagedProject().getConfigurations();
configSelector.removeAll();
configSelector.setItems(getConfigurationNames());
configSelector.select(configSelector.indexOf(name));
@@ -684,22 +528,9 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
return;
}
- private void handleOptionSelection() {
- // Get the selection from the tree list
- IStructuredSelection selection = (IStructuredSelection) optionList.getSelection();
-
- // Set the option page based on the selection
- Object element = selection.getFirstElement();
- if (element instanceof ITool) {
- displayOptionsForTool((ITool)element);
- } else if (element instanceof IOptionCategory) {
- displayOptionsForCategory((IOptionCategory)element);
- }
- }
-
- private void handleTargetSelection() {
+ private void handleProjectTypeSelection() {
// Is there anything in the selector widget
- if (targetSelector.getItemCount() == 0) {
+ if (projectTypeSelector.getItemCount() == 0) {
manageConfigs.setEnabled(false);
return;
}
@@ -708,233 +539,10 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
manageConfigs.setEnabled(true);
// Cache the platform at the selection index
- selectedTarget = targets[targetSelector.getSelectionIndex()];
- ManagedBuildManager.setSelectedTarget(getProject(), selectedTarget);
+ selectedProjectType = projectTypes[projectTypeSelector.getSelectionIndex()];
+ ManagedBuildManager.setSelectedConfiguration(getProject(), selectedConfiguration);
// Update the contents of the configuration widget
populateConfigurations();
}
-
- /*
- * (non-javadoc)
- * Initialize the relative weights (widths) of the 2 sides of the sash.
- */
- protected void initializeSashForm() {
- sashForm.setWeights(DEFAULT_SASH_WEIGHTS);
- }
-
- /* (non-Javadoc)
- * @param rawCommand
- * @return
- */
- private String parseMakeArgs(String rawCommand) {
- StringBuffer result = new StringBuffer();
-
- // Parse out the command
- String actualCommand = parseMakeCommand(rawCommand);
-
- // The flags and targets are anything not in the command
- String arguments = rawCommand.substring(actualCommand.length());
-
- // If there aren't any, we can stop
- if (arguments.length() == 0) {
- return result.toString().trim();
- }
-
- String[] tokens = arguments.trim().split("\\s"); //$NON-NLS-1$
- /*
- * Cases to consider
- * --<flag> Sensible, modern single flag. Add to result and continue.
- * -<flags> Flags in single token, add to result and stop
- * -<flag_with_arg> ARG Flag with argument. Add next token if valid arg.
- * -<mixed_flags> ARG Mix of flags, one takes arg. Add next token if valid arg.
- * -<flag_with_arg>ARG Corrupt case where next token should be arg but isn't
- * -<flags> [target].. Flags with no args, another token, add flags and stop.
- */
- Pattern flagPattern = Pattern.compile("C|f|I|j|l|O|W"); //$NON-NLS-1$
- // Look for a '-' followed by 1 or more flags with no args and exactly 1 that expects args
- Pattern mixedFlagWithArg = Pattern.compile("-[^CfIjloW]*[CfIjloW]{1}.+"); //$NON-NLS-1$
- for (int i = 0; i < tokens.length; ++i) {
- String currentToken = tokens[i];
- if (currentToken.startsWith("--")) { //$NON-NLS-1$
- result.append(currentToken);
- result.append(" "); //$NON-NLS-1$
- } else if (currentToken.startsWith("-")) { //$NON-NLS-1$
- // Is there another token
- if (i + 1 >= tokens.length) {
- //We are done
- result.append(currentToken);
- } else {
- String nextToken = tokens[i + 1];
- // Are we expecting arguments
- Matcher flagMatcher = flagPattern.matcher(currentToken);
- if (!flagMatcher.find()) {
- // Evalutate whether the next token should be added normally
- result.append(currentToken);
- result.append(" "); //$NON-NLS-1$
- } else {
- // Look for the case where there is no space between flag and arg
- if (mixedFlagWithArg.matcher(currentToken).matches()) {
- // Add this single token and keep going
- result.append(currentToken);
- result.append(" "); //$NON-NLS-1$
- } else {
- // Add this token and the next one right now
- result.append(currentToken);
- result.append(" "); //$NON-NLS-1$
- result.append(nextToken);
- result.append(" "); //$NON-NLS-1$
- // Skip the next token the next time through, though
- ++i;
- }
- }
- }
- }
- }
-
- return result.toString().trim();
- }
-
- /* (non-Javadoc)
- *
- * @param string
- * @return
- */
- private String parseMakeCommand(String rawCommand) {
- StringBuffer command = new StringBuffer();
- boolean hasSpace = false;
-
- // Try to separate out the command from the arguments
- String[] result = rawCommand.split("\\s"); //$NON-NLS-1$
-
- /*
- * Here are the cases to consider:
- * cmd First segment is last segment, assume is command
- * cmd [flags] First segment is the command
- * path/cmd [flags] Same as above
- * path with space/make [flags] Must append each segment up-to flags as command
- */
- for (int i = 0; i < result.length; ++i) {
- // Get the segment
- String cmdSegment = result[i];
- // If there is not another segment, we found the end
- if (i + 1 >= result.length) {
- command.append(cmdSegment);
- } else {
- // See if the next segment is the start of the flags
- String nextSegment = result[i + 1];
- if (nextSegment.startsWith("-")) { //$NON-NLS-1$
- // we have found the end of the command
- command.append(cmdSegment);
- break;
- } else {
- command.append(cmdSegment);
- // Add the whitespace back
- command.append(" "); //$NON-NLS-1$
- hasSpace = true;
- }
- }
- }
-
-// if (hasSpace == true) {
-// return "\"" + command.toString().trim() + "\"";
-// } else {
- return command.toString().trim();
-// }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- // Empty the page list
- List pages = getPagesForConfig();
- pages.clear();
-
- // Get the build manager to reset build info for project
- ManagedBuildManager.resetConfiguration(getProject(), getSelectedConfiguration());
-
- // Recreate the settings store for the configuration
- settingsStore = new BuildToolsSettingsStore(getSelectedConfiguration());
-
- // Write out the build model info
- ManagedBuildManager.setDefaultConfiguration(getProject(), getSelectedConfiguration());
- ManagedBuildManager.saveBuildInfo(getProject(), false);
-
- // Reset the category or tool selection and run selection event handler
- selectedCategory = null;
- selectedTool = null;
- handleOptionSelection();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- // Force each settings page to update
- List pages = getPagesForConfig();
- // Make sure we have something to work on
- if (pages == null) {
- // Nothing to do
- return true;
- }
- ListIterator iter = pages.listIterator();
- while (iter.hasNext()) {
- BuildSettingsPage page = (BuildSettingsPage) iter.next();
- if (page == null) continue;
- if (page instanceof BuildToolSettingsPage) {
- // if the currentsettings page is not the tool settings page
- // then update the all build options field editor based on the
- // build options in other options settings page.
- if (!(currentSettingsPage instanceof BuildToolSettingsPage))
- ((BuildToolSettingsPage)page).updateAllOptionField();
- ((BuildToolSettingsPage)page).performOk();
- } else if (page instanceof BuildOptionSettingsPage) {
- ((BuildOptionSettingsPage)page).performOk();
- }
- }
-
- // Write out the build model info
- ManagedBuildManager.setDefaultConfiguration(getProject(), getSelectedConfiguration());
- ManagedBuildManager.saveBuildInfo(getProject(), false);
- return true;
- }
-
- private void populateConfigurations() {
- // If the config select widget is not there yet, just stop
- if (configSelector == null) return;
-
- // Find the configurations defined for the platform
- configurations = selectedTarget.getConfigurations();
- if (configurations.length == 0) return;
-
- // Clear and replace the contents of the selector widget
- configSelector.removeAll();
- configSelector.setItems(getConfigurationNames());
-
- // Make sure the active configuration is selected
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
- IConfiguration defaultConfig = info.getDefaultConfiguration(selectedTarget);
- int index = configSelector.indexOf(defaultConfig.getName());
- configSelector.select(index == -1 ? 0 : index);
- handleConfigSelection();
- }
-
- /**
- * @see org.eclipse.jface.preference.IPreferencePageContainer#updateButtons()
- */
- public void updateButtons() {
- }
- /**
- * @see org.eclipse.jface.preference.IPreferencePageContainer#updateMessage()
- */
- public void updateMessage() {
- }
- /**
- * @see org.eclipse.jface.preference.IPreferencePageContainer#updateTitle()
- */
- public void updateTitle() {
- }
} \ No newline at end of file
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildSettingsPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildSettingsPage.java
index 2d9c5181631..c9aa6233f0a 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildSettingsPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildSettingsPage.java
@@ -1,5 +1,3 @@
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
/**********************************************************************
* Copyright (c) 2004 IBM Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
@@ -10,13 +8,20 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
* Contributors:
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.properties;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferencePageContainer;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.PropertyChangeEvent;
-public class BuildSettingsPage extends FieldEditorPreferencePage {
+public abstract class BuildSettingsPage extends FieldEditorPreferencePage {
protected IConfiguration configuration;
+ protected IResourceConfiguration resConfig;
+ private boolean dirty = false;
/**
* @param style
@@ -28,13 +33,56 @@ public class BuildSettingsPage extends FieldEditorPreferencePage {
configuration = config;
}
+ protected BuildSettingsPage(IResourceConfiguration resConfig) {
+ // Must be a grid layout and we don't want another set of buttons
+ super(GRID);
+ noDefaultAndApplyButton();
+ this.resConfig = resConfig;
+ }
/* (non-Javadoc)
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
*/
protected void createFieldEditors() {
// Get the preference store for the build settings
- IPreferenceStore settings = getPreferenceStore();
+ IPreferenceStore settings = getToolSettingsPreferenceStore();
setPreferenceStore(settings);
}
+ /**
+ * Return the tool settings preference store
+ */
+ protected IPreferenceStore getToolSettingsPreferenceStore() {
+ IPreferencePageContainer container = getContainer();
+ if (container instanceof BuildPropertyPage) {
+ return ((BuildPropertyPage)container).getToolSettingsPreferenceStore();
+ } else if ( container instanceof ResourceBuildPropertyPage) {
+ return ((ResourceBuildPropertyPage)container).getToolSettingsPreferenceStore();
+ }
+ return null;
+ }
+
+ /**
+ * Method called when the value of a dialog field changes
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ super.propertyChange(event);
+ if (event.getProperty().equals(FieldEditor.VALUE)) {
+ setDirty(true);
+ }
+ }
+
+ /**
+ * Sets the "dirty" state
+ */
+ public void setDirty(boolean b) {
+ dirty = b;
+ }
+
+ /**
+ * Returns the "dirty" state
+ */
+ public boolean isDirty() {
+ return dirty;
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java
index bc1cd780e04..091f0c8b25c 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
/**********************************************************************
- * Copyright (c) 2004 IBM Rational Software Corporation and others.
+ * Copyright (c) 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,6 +8,8 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
* Contributors:
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -20,10 +20,13 @@ import java.util.Vector;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
+import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.core.ToolReference;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.swt.graphics.Point;
@@ -49,16 +52,27 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
private ITool tool;
// Map that holds all user object options and its values
private HashMap userObjsMap;
+
+ private boolean isItResourceConfigPage;
- BuildToolSettingsPage(IConfiguration configuration, ITool tool) {
+ public BuildToolSettingsPage(IConfiguration configuration, ITool tool) {
// Cache the configuration and tool this page is for
super(configuration);
this.tool = tool;
allOptionsId = tool.getId() + ".allOptions"; //$NON-NLS-1$
stringOptionsMap = new HashMap();
userObjsMap = new HashMap();
+ isItResourceConfigPage = false;
+ }
+ public BuildToolSettingsPage(IResourceConfiguration resConfig, ITool tool) {
+ // Cache the configuration and tool this page is for
+ super(resConfig);
+ this.tool = tool;
+ allOptionsId = tool.getId() + ".allOptions"; //$NON-NLS-1$
+ stringOptionsMap = new HashMap();
+ userObjsMap = new HashMap();
+ isItResourceConfigPage = true;
}
-
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferencePage#computeSize()
*/
@@ -83,7 +97,8 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
// Add a field editor that displays over all build options
allOptionFieldEditor = new MultiLineTextFieldEditor(allOptionsId,
ALL_OPTIONS, getFieldEditorParent());
- getPreferenceStore().setValue(allOptionsId, ""); //$NON-NLS-1$
+ allOptionFieldEditor.getTextControl().setEditable(false);
+ getToolSettingsPreferenceStore().setValue(allOptionsId, ""); //$NON-NLS-1$
addField(allOptionFieldEditor);
}
@@ -157,6 +172,15 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
return output;
}
+
+ /**
+ * Look for $(VALUE) in the command string
+ */
+ private String evaluateCommand( String command, String values ) {
+ if( command == null ) return values.trim();
+ if( command.indexOf( "$(" ) > 0 ) return command.replaceAll( "\\$\\([value|Value|VALUE]\\)", values.trim() ).trim(); //$NON-NLS-1$ //$NON-NLS-2$
+ else return (new String(command + values)).trim();
+ }
/**
* Returns all the build options string
@@ -165,54 +189,45 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
* @throws BuildException
*/
private String getToolFlags() throws BuildException {
- ITool[] tools = configuration.getTools();
- for (int i = 0; i < tools.length; ++i) {
- if (tools[i] instanceof ToolReference) {
- if (((ToolReference) tools[i]).references(tool)) {
- tool = tools[i];
- break;
- }
- } else if (tools[i].equals(tool))
- break;
- }
StringBuffer buf = new StringBuffer();
+ ArrayList flags = new ArrayList();
// get the options for this tool
IOption[] options = tool.getOptions();
String listStr = ""; //$NON-NLS-1$
String[] listVal = null;
for (int k = 0; k < options.length; k++) {
IOption option = options[k];
+ buf.setLength( 0 );
switch (option.getValueType()) {
case IOption.BOOLEAN :
String boolCmd;
- if (getPreferenceStore().getBoolean(option.getId())) {
+ if (getToolSettingsPreferenceStore().getBoolean(option.getId())) {
boolCmd = option.getCommand();
} else {
// Note: getCommandFalse is new with CDT 2.0
boolCmd = option.getCommandFalse();
}
if (boolCmd != null && boolCmd.length() > 0) {
- buf.append(boolCmd + ITool.WHITE_SPACE);
+ buf.append(boolCmd);
}
break;
case IOption.ENUMERATED :
- String enumCommand = getPreferenceStore().getString(
+ String enumCommand = getToolSettingsPreferenceStore().getString(
option.getId());
if (enumCommand.indexOf(DEFAULT_SEPERATOR) != -1)
enumCommand = option.getSelectedEnum();
String enum = option.getEnumCommand(enumCommand);
if (enum.length() > 0) {
- buf.append(enum + ITool.WHITE_SPACE);
+ buf.append(enum);
}
break;
case IOption.STRING :
String strCmd = option.getCommand();
- String val = getPreferenceStore().getString(option.getId());
+ String val = getToolSettingsPreferenceStore().getString(option.getId());
// add this string option value to the list
stringOptionsMap.put(option, val);
if (val.length() > 0) {
- if (strCmd != null) buf.append(strCmd);
- buf.append(val + ITool.WHITE_SPACE);
+ buf.append(evaluateCommand( strCmd, val ));
}
break;
case IOption.STRING_LIST :
@@ -221,23 +236,30 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
case IOption.LIBRARIES :
case IOption.OBJECTS :
String cmd = option.getCommand();
- listStr = getPreferenceStore().getString(option.getId());
+ listStr = getToolSettingsPreferenceStore().getString(option.getId());
if (cmd == null)
userObjsMap.put(option, listStr);
listVal = BuildToolsSettingsStore.parseString(listStr);
for (int j = 0; j < listVal.length; j++) {
String temp = listVal[j];
- if (cmd != null)
- buf.append(cmd + temp + ITool.WHITE_SPACE);
- else
- buf.append(temp + ITool.WHITE_SPACE);
+ buf.append( evaluateCommand( cmd, temp ) + ITool.WHITE_SPACE);
}
break;
default :
break;
}
+ if( buf.toString().trim().length() > 0 ) flags.add( buf.toString().trim() );
+ }
+
+ String outputName = "temp"; //$NON-NLS-1$
+ if (tool.getInputExtensions().get(0) != null) {
+ outputName += tool.getInputExtensions().get(0);
}
- return buf.toString().trim();
+ String[] f = new String[ flags.size() ];
+ IManagedCommandLineGenerator gen = tool.getCommandLineGenerator();
+ IManagedCommandLineInfo info = gen.generateCommandLineInfo( tool, tool.getToolCommand(), (String[])flags.toArray( f ),
+ tool.getOutputFlag(), tool.getOutputPrefix(), outputName, new String[0], tool.getCommandLinePattern() );
+ return info.getFlags();
}
/**
@@ -259,18 +281,8 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
* field editor and stores the options to the corresponding option fields.
*/
public void parseAllOptions() {
- ITool[] tools = configuration.getTools();
- for (int i = 0; i < tools.length; ++i) {
- if (tools[i] instanceof ToolReference) {
- if (((ToolReference) tools[i]).references(tool)) {
- tool = tools[i];
- break;
- }
- } else if (tools[i].equals(tool))
- break;
- }
// Get the all build options string from all options field
- String alloptions = getPreferenceStore().getString(allOptionsId);
+ String alloptions = getToolSettingsPreferenceStore().getString(allOptionsId);
// list that holds the options for the option type other than
// boolean,string and enumerated
List optionsList = new ArrayList();
@@ -302,53 +314,55 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
// if the value does not exist in string option or user objects
// option
if (!optionValueExist) {
- // check whether the option value is already exist
- // and also change the preference store based on
- // the option value
- switch (opt.getValueType()) {
- case IOption.BOOLEAN :
- String boolCommand;
- boolCommand = opt.getCommand();
- if (boolCommand != null && boolCommand.equals(optionValue)) {
- getPreferenceStore()
- .setValue(opt.getId(), true);
- optionValueExist = true;
- }
- boolCommand = opt.getCommandFalse();
- if (boolCommand != null && boolCommand.equals(optionValue)) {
- getPreferenceStore()
- .setValue(opt.getId(), false);
- optionValueExist = true;
- }
- break;
- case IOption.ENUMERATED :
- String enum = ""; //$NON-NLS-1$
- String[] enumValues = opt.getApplicableValues();
- for (int i = 0; i < enumValues.length; i++) {
- if (opt.getEnumCommand(enumValues[i]).equals(
- optionValue)) {
- enum = enumValues[i];
+ try {
+ // check whether the option value is already exist
+ // and also change the preference store based on
+ // the option value
+ switch (opt.getValueType()) {
+ case IOption.BOOLEAN :
+ String boolCommand;
+ boolCommand = opt.getCommand();
+ if (boolCommand != null && boolCommand.equals(optionValue)) {
+ getToolSettingsPreferenceStore()
+ .setValue(opt.getId(), true);
optionValueExist = true;
}
- }
- if (!enum.equals("")) //$NON-NLS-1$
- getPreferenceStore()
- .setValue(opt.getId(), enum);
- break;
- case IOption.STRING_LIST :
- case IOption.INCLUDE_PATH :
- case IOption.PREPROCESSOR_SYMBOLS :
- case IOption.LIBRARIES :
- if (opt.getCommand() != null
- && optionValue.startsWith(opt
- .getCommand())) {
- optionsList.add(optionValue);
- optionValueExist = true;
- }
- break;
- default :
- break;
- }
+ boolCommand = opt.getCommandFalse();
+ if (boolCommand != null && boolCommand.equals(optionValue)) {
+ getToolSettingsPreferenceStore()
+ .setValue(opt.getId(), false);
+ optionValueExist = true;
+ }
+ break;
+ case IOption.ENUMERATED :
+ String enum = ""; //$NON-NLS-1$
+ String[] enumValues = opt.getApplicableValues();
+ for (int i = 0; i < enumValues.length; i++) {
+ if (opt.getEnumCommand(enumValues[i]).equals(
+ optionValue)) {
+ enum = enumValues[i];
+ optionValueExist = true;
+ }
+ }
+ if (!enum.equals("")) //$NON-NLS-1$
+ getToolSettingsPreferenceStore()
+ .setValue(opt.getId(), enum);
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ if (opt.getCommand() != null
+ && optionValue.startsWith(opt
+ .getCommand())) {
+ optionsList.add(optionValue);
+ optionValueExist = true;
+ }
+ break;
+ default :
+ break;
+ }
+ } catch (BuildException e) {}
}
}
// If the parsed string does not match with any previous option
@@ -373,7 +387,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
if (alloptions.indexOf(vals[t]) != -1)
buf.append(vals[t] + ITool.WHITE_SPACE);
}
- getPreferenceStore().setValue(((IOption) key).getId(),
+ getToolSettingsPreferenceStore().setValue(((IOption) key).getId(),
buf.toString().trim());
}
}
@@ -394,7 +408,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
String listArr[] = new String[list.size()];
list.toArray(listArr);
String liststr = BuildToolsSettingsStore.createList(listArr);
- getPreferenceStore().setValue(((IOption) key).getId(), liststr);
+ getToolSettingsPreferenceStore().setValue(((IOption) key).getId(), liststr);
}
}
// Now update the preference store with parsed options
@@ -405,52 +419,54 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
String name = opt.getId();
String listStr = ""; //$NON-NLS-1$
String[] listVal = null;
- switch (opt.getValueType()) {
- case IOption.BOOLEAN :
- ArrayList optsList = new ArrayList(optionsArr);
- if (opt.getCommand() != null
- && opt.getCommand().length() > 0
- && !optsList.contains(opt.getCommand()))
- getPreferenceStore().setValue(opt.getId(), false);
- if (opt.getCommandFalse() != null
- && opt.getCommandFalse().length() > 0
- && !optsList.contains(opt.getCommandFalse()))
- getPreferenceStore().setValue(opt.getId(), true);
- break;
- case IOption.STRING :
- // TODO create a lst of valid default string options for the tool
- if (getDefaultOptionNames().contains(opt.getName())) {
- String newOptions = getPreferenceStore().getString(
- opt.getId());
- if (addnOptions.length() > 0) {
- newOptions = newOptions + ITool.WHITE_SPACE
- + addnOptions.toString().trim();
+ try {
+ switch (opt.getValueType()) {
+ case IOption.BOOLEAN :
+ ArrayList optsList = new ArrayList(optionsArr);
+ if (opt.getCommand() != null
+ && opt.getCommand().length() > 0
+ && !optsList.contains(opt.getCommand()))
+ getToolSettingsPreferenceStore().setValue(opt.getId(), false);
+ if (opt.getCommandFalse() != null
+ && opt.getCommandFalse().length() > 0
+ && !optsList.contains(opt.getCommandFalse()))
+ getToolSettingsPreferenceStore().setValue(opt.getId(), true);
+ break;
+ case IOption.STRING :
+ // TODO create a lst of valid default string options for the tool
+ if (getDefaultOptionNames().contains(opt.getName())) {
+ String newOptions = getToolSettingsPreferenceStore().getString(
+ opt.getId());
+ if (addnOptions.length() > 0) {
+ newOptions = newOptions + ITool.WHITE_SPACE
+ + addnOptions.toString().trim();
+ }
+ getToolSettingsPreferenceStore().setValue(opt.getId(), newOptions);
}
- getPreferenceStore().setValue(opt.getId(), newOptions);
- }
- break;
- case IOption.STRING_LIST :
- case IOption.INCLUDE_PATH :
- case IOption.PREPROCESSOR_SYMBOLS :
- case IOption.LIBRARIES :
- ArrayList newList = new ArrayList();
- for (int i = 0; i < optionsList.size(); i++) {
- if (opt.getCommand() != null
- && ((String) optionsList.get(i)).startsWith(opt
- .getCommand())) {
- newList.add(((String) optionsList.get(i))
- .substring(opt.getCommand().length()));
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ ArrayList newList = new ArrayList();
+ for (int i = 0; i < optionsList.size(); i++) {
+ if (opt.getCommand() != null
+ && ((String) optionsList.get(i)).startsWith(opt
+ .getCommand())) {
+ newList.add(((String) optionsList.get(i))
+ .substring(opt.getCommand().length()));
+ }
}
- }
- String[] strlist = new String[newList.size()];
- newList.toArray(strlist);
- newList.clear();
- getPreferenceStore().setValue(opt.getId(),
- BuildToolsSettingsStore.createList(strlist));
- break;
- default :
- break;
- }
+ String[] strlist = new String[newList.size()];
+ newList.toArray(strlist);
+ newList.clear();
+ getToolSettingsPreferenceStore().setValue(opt.getId(),
+ BuildToolsSettingsStore.createList(strlist));
+ break;
+ default :
+ break;
+ }
+ } catch (BuildException e) {}
}
}
@@ -462,61 +478,84 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
boolean result = super.performOk();
//parse and store all build options in the corresponding preference store
- parseAllOptions();
+ //parseAllOptions();
// Write the preference store values back to the build model
- ITool[] tools = configuration.getTools();
- for (int i = 0; i < tools.length; ++i) {
- if (tools[i] instanceof ToolReference) {
- if (((ToolReference) tools[i]).references(tool)) {
- tool = tools[i];
- break;
- }
- } else if (tools[i].equals(tool)) {
- break;
- }
+ IOptionCategory category = (IOptionCategory)tool;
+ Object[][] options;
+ if ( isItResourceConfigPage ) {
+ options = category.getOptions(resConfig);
+ } else {
+ options = category.getOptions(configuration);
}
- IOption[] options = tool.getOptions();
+ if ( options == null)
+ return true;
+
for (int i = 0; i < options.length; i++) {
- IOption option = options[i];
- // Transfer value from preference store to options
- switch (option.getValueType()) {
- case IOption.BOOLEAN :
- boolean boolVal = getPreferenceStore().getBoolean(option.getId());
- ManagedBuildManager.setOption(configuration, option, boolVal);
- break;
- case IOption.ENUMERATED :
- String enumVal = getPreferenceStore().getString(option.getId());
- String enumId = option.getEnumeratedId(enumVal);
- ManagedBuildManager.setOption(configuration, option,
+ ITool tool = (ITool)options[i][0];
+ if (tool == null) break; // The array may not be full
+ IOption option = (IOption)options[i][1];
+ try {
+ // Transfer value from preference store to options
+ IOption setOption;
+ switch (option.getValueType()) {
+ case IOption.BOOLEAN :
+ boolean boolVal = getToolSettingsPreferenceStore().getBoolean(option.getId());
+ setOption = ManagedBuildManager.setOption(configuration, tool, option, boolVal);
+ // Reset the preference store since the Id may have changed
+ if (setOption != option) {
+ getToolSettingsPreferenceStore().setValue(setOption.getId(), boolVal);
+ }
+ break;
+ case IOption.ENUMERATED :
+ String enumVal = getToolSettingsPreferenceStore().getString(option.getId());
+ String enumId = option.getEnumeratedId(enumVal);
+ setOption = ManagedBuildManager.setOption(configuration, tool, option,
(enumId != null && enumId.length() > 0) ? enumId : enumVal);
- break;
- case IOption.STRING :
- String strVal = getPreferenceStore().getString(option.getId());
- ManagedBuildManager.setOption(configuration, option, strVal);
- break;
- case IOption.STRING_LIST :
- case IOption.INCLUDE_PATH :
- case IOption.PREPROCESSOR_SYMBOLS :
- case IOption.LIBRARIES :
- case IOption.OBJECTS :
- String listStr = getPreferenceStore().getString(option.getId());
- String[] listVal = BuildToolsSettingsStore.parseString(listStr);
- ManagedBuildManager.setOption(configuration, option, listVal);
- break;
- default :
- break;
- }
+ // Reset the preference store since the Id may have changed
+ if (setOption != option) {
+ getToolSettingsPreferenceStore().setValue(setOption.getId(), enumVal);
+ }
+ break;
+ case IOption.STRING :
+ String strVal = getToolSettingsPreferenceStore().getString(option.getId());
+ setOption = ManagedBuildManager.setOption(configuration, tool, option, strVal);
+ // Reset the preference store since the Id may have changed
+ if (setOption != option) {
+ getToolSettingsPreferenceStore().setValue(setOption.getId(), strVal);
+ }
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ String listStr = getToolSettingsPreferenceStore().getString(option.getId());
+ String[] listVal = BuildToolsSettingsStore.parseString(listStr);
+ setOption = ManagedBuildManager.setOption(configuration, tool, option, listVal);
+ // Reset the preference store since the Id may have changed
+ if (setOption != option) {
+ getToolSettingsPreferenceStore().setValue(setOption.getId(), listStr);
+ }
+ break;
+ default :
+ break;
+ }
+ } catch (BuildException e) {}
}
// Get the actual value out of the field editor
- String command = getPreferenceStore().getString(tool.getId());
+ String command = getToolSettingsPreferenceStore().getString(tool.getId());
if (command.length() == 0) {
return result;
}
// Ask the build system manager to change the tool command
- ManagedBuildManager.setToolCommand(configuration, tool, command);
+ if ( isItResourceConfigPage ) {
+ ManagedBuildManager.setToolCommand(resConfig, tool, command);
+ } else {
+ ManagedBuildManager.setToolCommand(configuration, tool, command);
+ }
return result;
}
@@ -534,7 +573,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
public void updateAllOptionField() {
try {
if (getToolFlags() != null) {
- getPreferenceStore().setValue(allOptionsId, getToolFlags());
+ getToolSettingsPreferenceStore().setValue(allOptionsId, getToolFlags());
allOptionFieldEditor.load();
}
} catch (BuildException e) {
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolsSettingsStore.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolsSettingsStore.java
index 9507da90b54..1aa7a628db2 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolsSettingsStore.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolsSettingsStore.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * Copyright (c) 2002,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,6 +8,7 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
* Contributors:
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.properties;
import java.util.HashMap;
import java.util.Map;
@@ -18,6 +17,7 @@ import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
@@ -32,7 +32,10 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
private Map settingsMap;
private boolean dirtyFlag;
private IConfiguration owner;
-
+
+ private IResourceConfiguration resConfigOwner;
+// private IFile file;
+
/**
*
*/
@@ -47,11 +50,22 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
public BuildToolsSettingsStore (IConfiguration config) {
this();
owner = config;
+ resConfigOwner = null;
// Now populate the options map
populateSettingsMap();
}
-
+ public BuildToolsSettingsStore(IResourceConfiguration resConfig) {
+ this();
+ // owner = resConfig.getParent();
+ owner = null;
+ resConfigOwner = resConfig;
+ populateSettingsMap();
+ }
+ /**
+ *
+ */
+
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
*/
@@ -213,86 +227,98 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
getOptionsForCategory(children[i]);
}
// Else get the options for this category and add them to the map
- IOption [] options = cat.getOptions(owner);
+ Object[][] options;
+ if(resConfigOwner != null) {
+ options = cat.getOptions(resConfigOwner);
+ } else {
+ options = cat.getOptions(owner);
+ }
+
+ if ( options == null)
+ return;
for (int j = 0; j < options.length; ++j) {
- IOption opt = options[j];
+ ITool tool = (ITool)options[j][0];
+ if (tool == null) break; // The array may not be full
+ IOption opt = (IOption)options[j][1];
String name = opt.getId();
Object value;
- // Switch on the type of option
- switch (opt.getValueType()) {
- case IOption.BOOLEAN :
- try {
- value = new Boolean(opt.getBooleanValue());
- } catch (BuildException e) {
- // Exception occurs if there's an option value type mismatch
+ try {
+ // Switch on the type of option
+ switch (opt.getValueType()) {
+ case IOption.BOOLEAN :
+ try {
+ value = new Boolean(opt.getBooleanValue());
+ } catch (BuildException e) {
+ // Exception occurs if there's an option value type mismatch
+ break;
+ }
+ getSettingsMap().put(name, value);
+ break;
+
+ case IOption.ENUMERATED :
+ try{
+ String selId;
+ selId = opt.getSelectedEnum();
+ value = opt.getEnumName(selId);
+ } catch (BuildException e) {
+ break;
+ }
+ getSettingsMap().put(name, value);
break;
- }
- getSettingsMap().put(name, value);
- break;
-
- case IOption.ENUMERATED :
- try{
- String selId;
- selId = opt.getSelectedEnum();
- value = opt.getEnumName(selId);
- } catch (BuildException e) {
+
+ case IOption.STRING :
+ try {
+ value = opt.getStringValue();
+ } catch (BuildException e) {
+ break;
+ }
+ getSettingsMap().put(name, value);
break;
- }
- getSettingsMap().put(name, value);
- break;
-
- case IOption.STRING :
- try {
- value = opt.getStringValue();
- } catch (BuildException e) {
+
+ case IOption.STRING_LIST :
+ try {
+ value = createList(opt.getStringListValue());
+ } catch (BuildException e) {
+ break;
+ }
+ getSettingsMap().put(name, value);
break;
- }
- getSettingsMap().put(name, value);
- break;
-
- case IOption.STRING_LIST :
- try {
- value = createList(opt.getStringListValue());
- } catch (BuildException e) {
+ case IOption.INCLUDE_PATH :
+ try {
+ value = createList(opt.getIncludePaths());
+ } catch (BuildException e) {
+ break;
+ }
+ getSettingsMap().put(name, value);
break;
- }
- getSettingsMap().put(name, value);
- break;
- case IOption.INCLUDE_PATH :
- try {
- value = createList(opt.getIncludePaths());
- } catch (BuildException e) {
+ case IOption.PREPROCESSOR_SYMBOLS :
+ try {
+ value = createList(opt.getDefinedSymbols());
+ } catch (BuildException e) {
+ break;
+ }
+ getSettingsMap().put(name, value);
break;
- }
- getSettingsMap().put(name, value);
- break;
- case IOption.PREPROCESSOR_SYMBOLS :
- try {
- value = createList(opt.getDefinedSymbols());
- } catch (BuildException e) {
+ case IOption.LIBRARIES :
+ try {
+ value = createList(opt.getLibraries());
+ } catch (BuildException e) {
+ break;
+ }
+ getSettingsMap().put(name, value);
break;
- }
- getSettingsMap().put(name, value);
- break;
- case IOption.LIBRARIES :
- try {
- value = createList(opt.getLibraries());
- } catch (BuildException e) {
+ case IOption.OBJECTS :
+ try {
+ value = createList(opt.getUserObjects());
+ } catch (BuildException e) {
+ break;
+ }
+ getSettingsMap().put(name, value);
break;
- }
- getSettingsMap().put(name, value);
- break;
- case IOption.OBJECTS :
- try {
- value = createList(opt.getUserObjects());
- } catch (BuildException e) {
+ default :
break;
- }
- getSettingsMap().put(name, value);
- break;
- default :
- break;
- }
+ }
+ } catch (BuildException e) {}
}
}
@@ -340,7 +366,16 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
*/
private void populateSettingsMap() {
// Each configuration has a list of tools
- ITool [] tools = owner.getTools();
+ ITool [] tools;
+
+ // If resConfigOwner is not null, get the resource specific tools.
+
+ if ( resConfigOwner != null) {
+ tools = resConfigOwner.getTools();
+ } else {
+ tools = owner.getFilteredTools();
+ }
+
for (int index = 0; index < tools.length; ++index) {
// Add the tool to the map
ITool tool = tools[index];
@@ -468,4 +503,16 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
}
+ /**
+ * @return Returns the resConfigOwner.
+ */
+ public IResourceConfiguration getResConfigOwner() {
+ return resConfigOwner;
+ }
+ /**
+ * @param resConfigOwner The resConfigOwner to set.
+ */
+ public void setResConfigOwner(IResourceConfiguration resConfigOwner) {
+ this.resConfigOwner = resConfigOwner;
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ManageConfigDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ManageConfigDialog.java
index f2ab6057607..3cd684bfd79 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ManageConfigDialog.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ManageConfigDialog.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
/**********************************************************************
- * Copyright (c) 2002,2004 Rational Software Corporation and others.
+ * Copyright (c) 2002,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,21 +8,19 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.properties;
import java.util.ArrayList;
import java.util.SortedMap;
import java.util.TreeMap;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
@@ -38,7 +34,6 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
public class ManageConfigDialog extends Dialog {
// String constants
@@ -49,41 +44,27 @@ public class ManageConfigDialog extends Dialog {
private static final String PREFIX = "ManageConfig"; //$NON-NLS-1$
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
private static final String RESTORE = LABEL + ".restore"; //$NON-NLS-1$
- private static final String GROUP = LABEL + ".makecmdgroup"; //$NON-NLS-1$
- private static final String DEF_BTN = LABEL + ".makecmddef"; //$NON-NLS-1$
- private static final String OUTPUT_GROUP = LABEL + ".output.group"; //$NON-NLS-1$
- private static final String OUTPUT_EXT = LABEL + ".output.extension"; //$NON-NLS-1$
- private static final String OUTPUT_NAME = LABEL + ".output.name"; //$NON-NLS-1$
private static final String CONFIGS = LABEL + ".configs"; //$NON-NLS-1$
private static final String CURRENT_CONFIGS = CONFIGS + ".current"; //$NON-NLS-1$
private static final String DELETED_CONFIGS = CONFIGS + ".deleted"; //$NON-NLS-1$
private static final String CONF_DLG = LABEL + ".new.config.dialog"; //$NON-NLS-1$
- // The name of the build artifact
- private String artifactExt;
- private String artifactName;
+ private static final String EMPTY_STRING = new String();
+
// The list of configurations to delete
private SortedMap deletedConfigs;
// Map of configuration names and ids
private SortedMap existingConfigs;
- // The make command associated with the target
- private String makeCommand;
// The target the configs belong to
- private ITarget managedTarget;
+ private IManagedProject managedProject;
// Map of new configurations chosen by the user
private SortedMap newConfigs;
// The title of the dialog.
private String title = ""; //$NON-NLS-1$
- // State of the check box on exit
- private boolean useDefaultMake;
// Widgets
- protected Text buildArtifactExt;
- protected Text buildArtifactName;
protected List currentConfigList;
protected List deletedConfigList;
- protected Button makeCommandDefault;
- protected Text makeCommandEntry;
protected Button newBtn;
protected Button okBtn;
protected Button removeBtn;
@@ -92,20 +73,14 @@ public class ManageConfigDialog extends Dialog {
/**
* @param parentShell
*/
- protected ManageConfigDialog(Shell parentShell, String title, ITarget target) {
+ protected ManageConfigDialog(Shell parentShell, String title, IManagedProject proj) {
super(parentShell);
this.title = title;
- this.managedTarget = target;
-
- setMakeCommand();
-
- // Get the name of the build artifact
- artifactExt = managedTarget.getArtifactExtension();
- artifactName = managedTarget.getArtifactName();
+ this.managedProject = proj;
// Get the defined configurations from the target
getExistingConfigs().clear();
- IConfiguration [] configs = managedTarget.getConfigurations();
+ IConfiguration [] configs = managedProject.getConfigurations();
for (int i = 0; i < configs.length; i++) {
IConfiguration configuration = configs[i];
getExistingConfigs().put(configuration.getName(), configuration.getId());
@@ -114,22 +89,6 @@ public class ManageConfigDialog extends Dialog {
getDeletedConfigs().clear();
getNewConfigs().clear();
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
- */
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.OK_ID) {
- useDefaultMake = makeCommandDefault.getSelection();
- makeCommand = makeCommandEntry.getText().trim();
- artifactName = buildArtifactName.getText().trim();
- artifactExt = buildArtifactExt.getText().trim();
- } else {
- useDefaultMake = true;
- artifactName = managedTarget.getArtifactName();
- }
- super.buttonPressed(buttonId);
- }
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
@@ -139,72 +98,6 @@ public class ManageConfigDialog extends Dialog {
if (title != null)
shell.setText(title);
}
-
- /* (non-Javadoc)
- * Creates the group that contains the build artifact name controls.
- */
- private void createBuildArtifactGroup(Composite parent) {
- final Group outputGroup = new Group(parent, SWT.NONE);
- outputGroup.setFont(parent.getFont());
- outputGroup.setText(ManagedBuilderUIMessages.getResourceString(OUTPUT_GROUP));
- outputGroup.setLayout(new GridLayout(3, false));
- outputGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Three labels
- final Label nameLabel = new Label(outputGroup, SWT.LEFT);
- nameLabel.setFont(outputGroup.getFont());
- nameLabel.setText(ManagedBuilderUIMessages.getResourceString(OUTPUT_NAME));
- nameLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- final Label placeHolder = new Label(outputGroup, SWT.CENTER);
- placeHolder.setText(new String());
- placeHolder.setLayoutData(new GridData());
-
- final Label extLabel = new Label(outputGroup, SWT.LEFT);
- extLabel.setFont(outputGroup.getFont());
- extLabel.setText(ManagedBuilderUIMessages.getResourceString(OUTPUT_EXT));
- extLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Now we need two text widgets separated by a label
- buildArtifactName = new Text(outputGroup, SWT.SINGLE | SWT.BORDER);
- buildArtifactName.setFont(outputGroup.getFont());
- buildArtifactName.setText(artifactName);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
- buildArtifactName.setLayoutData(data);
- buildArtifactName.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- buildArtifactName = null;
- }
- });
- buildArtifactName.getAccessible().addAccessibleListener(new AccessibleAdapter(){
- public void getName(AccessibleEvent e) {
- e.result = ManagedBuilderUIMessages.getResourceString(OUTPUT_NAME);
- }
- });
-
- final Label dotLabel = new Label(outputGroup, SWT.CENTER);
- dotLabel.setFont(outputGroup.getFont());
- dotLabel.setText(new String(".")); //$NON-NLS-1$
- dotLabel.setLayoutData(new GridData());
-
- buildArtifactExt = new Text(outputGroup, SWT.SINGLE | SWT.BORDER);
- buildArtifactExt.setFont(outputGroup.getFont());
- buildArtifactExt.setText(artifactExt);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = (IDialogConstants.ENTRY_FIELD_WIDTH / 2);
- buildArtifactExt.setLayoutData(data);
- buildArtifactExt.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- buildArtifactExt = null;
- }
- });
- buildArtifactExt.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- e.result = ManagedBuilderUIMessages.getResourceString(OUTPUT_EXT);
- }
- });
- }
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
@@ -325,12 +218,6 @@ public class ManageConfigDialog extends Dialog {
comp.setLayout(new GridLayout(1, true));
comp.setLayoutData(new GridData(GridData.FILL_BOTH));
- // Create a group for the build output
- createBuildArtifactGroup(comp);
-
- // Create the make command group area
- createMakeCommandGroup(comp);
-
// Make the configuration management area
createConfigListGroup(comp);
@@ -341,64 +228,6 @@ public class ManageConfigDialog extends Dialog {
return comp;
}
- /* (non-Javadoc)
- * Creates the group control for the make command
- * @param parent
- */
- private void createMakeCommandGroup(Composite parent) {
- final Group makeCommandGroup = new Group(parent, SWT.NONE);
- makeCommandGroup.setFont(parent.getFont());
- makeCommandGroup.setText(ManagedBuilderUIMessages.getResourceString(GROUP));
- makeCommandGroup.setLayout(new GridLayout(1, true));
- makeCommandGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- makeCommandDefault = new Button(makeCommandGroup, SWT.CHECK | SWT.LEFT);
- makeCommandDefault.setFont(makeCommandGroup.getFont());
- makeCommandDefault.setText(ManagedBuilderUIMessages.getResourceString(DEF_BTN));
- setButtonLayoutData(makeCommandDefault);
- makeCommandDefault.setBackground(makeCommandGroup.getBackground());
- makeCommandDefault.setForeground(makeCommandGroup.getForeground());
- makeCommandDefault.setSelection(!managedTarget.hasOverridenMakeCommand());
- makeCommandDefault.addSelectionListener(new SelectionAdapter () {
- public void widgetSelected(SelectionEvent e) {
- handleUseDefaultPressed();
- }
- });
- makeCommandDefault.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- makeCommandDefault = null;
- }
- });
-
- makeCommandEntry = new Text(makeCommandGroup, SWT.SINGLE | SWT.BORDER);
- makeCommandEntry.setFont(makeCommandGroup.getFont());
- makeCommandEntry.setEditable(!makeCommandDefault.getSelection());
- makeCommandEntry.setText(makeCommand);
- makeCommandEntry.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- makeCommandEntry.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- makeCommandEntry = null;
- }
- });
- }
-
- /**
- * Answers the extension for the build artifact.
- * @return
- */
- public String getBuildArtifaceExtension() {
- return artifactExt;
- }
-
- /**
- * Answers the value in the build artifact entry widget.
- *
- * @return
- */
- public String getBuildArtifactName() {
- return artifactName;
- }
-
private String [] getConfigurationNames() {
return (String[]) getExistingConfigs().keySet().toArray(new String[getExistingConfigs().size()]);
}
@@ -432,15 +261,6 @@ public class ManageConfigDialog extends Dialog {
}
/**
- * Answers the value in the make command entry widget.
- *
- * @return
- */
- public String getMakeCommand() {
- return makeCommand;
- }
-
- /**
* Answers a map of configuration names to <code>IConfiguration</code>.
* The name is selected by the user and should be unique for the target
* it will be added to. The configuration is the what the new
@@ -456,28 +276,18 @@ public class ManageConfigDialog extends Dialog {
}
/*
- * @return the <code>IProject</code> associated with the target
+ * @return the <code>IProject</code> associated with the managed project
*/
private IProject getProject() {
- return managedTarget.getOwner().getProject();
+ return (IProject)managedProject.getOwner();
}
/*
* Event handler for the add button
*/
protected void handleNewPressed() {
- // Find the defined target
- ITarget parentTarget = null;
- ITarget [] targets = ManagedBuildManager.getDefinedTargets(getProject());
- for (int i = 0; i < targets.length; i++) {
- ITarget target = targets[i];
- if (target.getId().equals(managedTarget.getParent().getId())) {
- parentTarget = target;
- break;
- }
- }
NewConfigurationDialog dialog = new NewConfigurationDialog(getShell(),
- managedTarget,
+ managedProject,
ManagedBuilderUIMessages.getResourceString(CONF_DLG));
if (dialog.open() == NewConfigurationDialog.OK) {
// Get the new name and configuration to base the new config on
@@ -535,7 +345,7 @@ public class ManageConfigDialog extends Dialog {
// If this was a new config (it won't be in the existing list) then add it back there
if (!getExistingConfigs().containsKey(selectedConfigName)) {
- IConfiguration restoredConfig = managedTarget.getConfiguration(selectedConfigId);
+ IConfiguration restoredConfig = managedProject.getConfiguration(selectedConfigId);
getNewConfigs().put(selectedConfigName, restoredConfig);
}
@@ -551,46 +361,10 @@ public class ManageConfigDialog extends Dialog {
}
}
- /* (non-Javadoc)
- * Event handler for the use default check box in the make command group
- */
- protected void handleUseDefaultPressed() {
- // If the state of the button is unchecked, then we want to enable the edit widget
- boolean checked = makeCommandDefault.getSelection();
- if (checked == true) {
- managedTarget.resetMakeCommand();
- setMakeCommand();
- makeCommandEntry.setText(makeCommand);
- makeCommandEntry.setEditable(false);
- } else {
- makeCommandEntry.setEditable(true);
- }
- }
-
- /*
- *
- */
- private void setMakeCommand() {
- // Figure out the make command
- makeCommand = managedTarget.getMakeCommand();
- String makeArgs = managedTarget.getMakeArguments();
- if (makeArgs.length() > 0) {
- makeCommand += " " + makeArgs; //$NON-NLS-1$
- }
- }
-
private void updateButtons() {
// Disable the remove button if there is only 1 configuration
removeBtn.setEnabled(currentConfigList.getItemCount() > 1);
// Enable the restore button if there is anything in the deleted list
restoreBtn.setEnabled(deletedConfigList.getItemCount() > 0);
}
-
- /**
- * Answers <code>true</code> if the user has left the use default check box selected.
- * @return
- */
- public boolean useDefaultMakeCommand () {
- return useDefaultMake;
- }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ManagedBuilderPropertyPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ManagedBuilderPropertyPage.java
deleted file mode 100644
index a8d27fab4a6..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ManagedBuilderPropertyPage.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Intel Corp - use in Managed Make system
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedProjectOptionBlock;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
-import org.eclipse.cdt.managedbuilder.internal.ui.ErrorParserBlock;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.preference.IPreferencePageContainer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
-import org.eclipse.ui.dialogs.PropertyPage;
-
-public class ManagedBuilderPropertyPage extends PropertyPage implements ICOptionContainer {
-
- protected ManagedProjectOptionBlock fOptionBlock;
- protected ITarget displayedTarget;
-
- private static final String MSG_CLOSEDPROJECT = "MngMakeProjectPropertyPage.closedproject"; //$NON-NLS-1$
-
- public ManagedBuilderPropertyPage() {
- super();
- }
-
- public void setContainer(IPreferencePageContainer preferencePageContainer) {
- super.setContainer(preferencePageContainer);
- if (fOptionBlock == null) {
- fOptionBlock = new ManagedProjectOptionBlock(this);
- }
- }
-
- protected Control createContents(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new FillLayout());
-
- IProject project = getProject();
- if (!project.isOpen()) {
- contentForClosedProject(composite);
- } else {
- contentForCProject(composite);
- }
-
- return composite;
- }
-
- private void contentForCProject(Composite parent) {
- fOptionBlock.createContents(parent);
- // WorkbenchHelp.setHelp(parent, ICMakeHelpContextIds.PROJECT_PROPERTY_PAGE);
- }
-
- private void contentForClosedProject(Composite parent) {
- Label label = new Label(parent, SWT.LEFT);
- label.setText(ManagedBuilderUIMessages.getResourceString(MSG_CLOSEDPROJECT));
- label.setFont(parent.getFont());
-
- noDefaultAndApplyButton();
- }
-
- /**
- * @see PreferencePage#performOk
- */
- public boolean performOk() {
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) {
- fOptionBlock.performApply(monitor);
- }
- };
-
- // If the user did not come to this page when the current selected target
- // was the selected target, then there is nothing to do. The page was either
- // never visited, or was visited for another target.
- ITarget target = getSelectedTarget();
- if (target != displayedTarget) return true;
-
- IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
- try {
- new ProgressMonitorDialog(getShell()).run(false, true, op);
- } catch (InvocationTargetException e) {
- Throwable e1 = e.getTargetException();
- ManagedBuilderUIPlugin.errorDialog(getShell(), ManagedBuilderUIMessages.getResourceString("ManagedProjectPropertyPage.internalError"),e1.toString(), e1); //$NON-NLS-1$
- return false;
- } catch (InterruptedException e) {
- // cancelled
- return false;
- }
-
- // Write out the build model info
- IProject project = getProject();
- ManagedBuildManager.saveBuildInfo(project, false);
- return true;
- }
-
- public IProject getProject() {
- Object element = getElement();
- if (element instanceof IProject) {
- return (IProject) element;
- }
- return null;
- }
-
- /**
- * @see DialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- fOptionBlock.setVisible(visible);
- if (visible) {
- ErrorParserBlock errorParsers = fOptionBlock.getErrorParserBlock();
- errorParsers.updateValues();
- displayedTarget = getSelectedTarget();
- }
- }
-
- protected ITarget getSelectedTarget() {
- // If the selected target is not yet set, set it to the default target
- // The selected target is needed for saving error parser information
- IProject project = getProject();
- ITarget target = ManagedBuildManager.getSelectedTarget(project);
- if (target == null) {
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- target = info.getDefaultTarget();
- ManagedBuildManager.setSelectedTarget(project, target);
- }
- return target;
- }
-
- public void updateContainer() {
- fOptionBlock.update();
- setValid(fOptionBlock.isValid());
- setErrorMessage(fOptionBlock.getErrorMessage());
- }
-
- protected void performDefaults() {
- fOptionBlock.performDefaults();
- super.performDefaults();
- }
-
- public boolean isValid() {
- updateContainer();
- return super.isValid();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getPreferences()
- */
- public Preferences getPreferences() {
- return null;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java
index 082e15c71ea..0d15f977758 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
/**********************************************************************
- * Copyright (c) 2003,2004 IBM Rational Software Corporation and others.
+ * Copyright (c) 2003,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,9 +8,11 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.properties;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
@@ -59,7 +59,7 @@ public class NewConfigurationDialog extends Dialog {
private IConfiguration[] defaultConfigs;
private IConfiguration[] definedConfigs;
private IConfiguration parentConfig;
- private ITarget target;
+ private IManagedProject managedProject;
private String newName;
private String title = ""; //$NON-NLS-1$
@@ -67,21 +67,21 @@ public class NewConfigurationDialog extends Dialog {
/**
* @param parentShell
*/
- protected NewConfigurationDialog(Shell parentShell, ITarget managedTarget, String title) {
+ protected NewConfigurationDialog(Shell parentShell, IManagedProject managedProject, String title) {
super(parentShell);
this.title = title;
setShellStyle(getShellStyle()|SWT.RESIZE);
newName = new String();
parentConfig = null;
- this.target = managedTarget;
+ this.managedProject = managedProject;
// The default behaviour is to clone the settings
clone = true;
// Populate the list of default and defined configurations
- definedConfigs = target.getConfigurations();
- ITarget grandparent = target.getParent();
- defaultConfigs = grandparent.getConfigurations();
+ definedConfigs = managedProject.getConfigurations();
+ IProjectType projectType = managedProject.getProjectType();
+ defaultConfigs = projectType.getConfigurations();
}
/* (non-Javadoc)
@@ -242,7 +242,7 @@ public class NewConfigurationDialog extends Dialog {
}
/*
- * Returns the array of configuration names defined for all targets
+ * Returns the array of configuration names defined for all projects
* of this type in the plugin manifest. This list will be used to
* populate the the configurations to copy default settings from.
*/
@@ -256,7 +256,7 @@ public class NewConfigurationDialog extends Dialog {
}
/*
- * Returns the array of configuration names defined for this target.
+ * Returns the array of configuration names defined for this managed project.
* This list will be used to populate the list of configurations to
* clone.
*/
@@ -285,11 +285,11 @@ public class NewConfigurationDialog extends Dialog {
* @return
*/
protected boolean isDuplicateName(String newName) {
- // Return true if there is already a config of that name defined on the target
- IConfiguration [] configs = target.getConfigurations();
+ // Return true if there is already a config of that name defined
+ IConfiguration [] configs = managedProject.getConfigurations();
for (int index = 0; index < configs.length; index++) {
IConfiguration configuration = configs[index];
- if (configuration.getName() == newName) {
+ if (configuration.getName().equals(newName)) {
return true;
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ResourceBuildPropertyPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ResourceBuildPropertyPage.java
new file mode 100644
index 00000000000..1d52e20fd44
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ResourceBuildPropertyPage.java
@@ -0,0 +1,487 @@
+/**********************************************************************
+ * Copyright (c) 2004 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import java.lang.reflect.InvocationTargetException;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock;
+import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
+import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
+import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
+import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+import org.eclipse.ui.dialogs.PropertyPage;
+import org.eclipse.ui.help.WorkbenchHelp;
+
+
+public class ResourceBuildPropertyPage extends PropertyPage implements
+ IWorkbenchPropertyPage, IPreferencePageContainer, ICOptionContainer {
+ /*
+ * String constants
+ */
+ private static final String PREFIX = "ResourceBuildPropertyPage"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String NAME_LABEL = LABEL + ".NameText"; //$NON-NLS-1$
+ private static final String CONFIG_LABEL = LABEL + ".Configuration"; //$NON-NLS-1$
+ private static final String ALL_CONFS = PREFIX + ".selection.configuration.all"; //$NON-NLS-1$
+ private static final String ACTIVE_RESOURCE_LABEL = LABEL + ".ActiveResource"; //$NON-NLS-1$
+ private static final String RESOURCE_SETTINGS_LABEL = LABEL + ".ResourceSettings"; //$NON-NLS-1$
+ private static final String TREE_LABEL = LABEL + ".ToolTree"; //$NON-NLS-1$
+ private static final String OPTIONS_LABEL = LABEL + ".ToolOptions"; //$NON-NLS-1$
+ private static final String EXCLUDE_CHECKBOX = LABEL + ".ExcludeCheckBox"; //$NON-NLS-1$
+ private static final String TIP = PREFIX + ".tip"; //$NON-NLS-1$
+ private static final String RESOURCE_PLAT_TIP = TIP + ".ResourcePlatform"; //$NON-NLS-1$
+ private static final String CONF_TIP = TIP + ".config"; //$NON-NLS-1$
+ private static final String EXCLUDE_TIP = TIP + ".excludecheck"; //$NON-NLS-1$
+ private static final String MANAGE_TITLE = PREFIX + ".manage.title"; //$NON-NLS-1$
+ private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { 20, 30 };
+ private static final String ID_SEPARATOR = "."; //$NON-NLS-1$
+
+ /*
+ * Dialog widgets
+ */
+
+ private Combo configSelector;
+
+// private Point lastShellSize;
+ private Button excludedCheckBox;
+ private boolean isExcluded = false;
+
+ /*
+ * Bookeeping variables
+ */
+
+
+ private IConfiguration[] configurations;
+ private IConfiguration selectedConfiguration;
+ private IResourceConfiguration currentResourceConfig;
+ private Point lastShellSize;
+ protected ManagedBuildOptionBlock fOptionBlock;
+ protected boolean displayedConfig = false;
+ /**
+ * Default constructor
+ */
+ public ResourceBuildPropertyPage() {
+ // super();
+ }
+
+ public void setContainer(IPreferencePageContainer preferencePageContainer) {
+ super.setContainer(preferencePageContainer);
+ if (fOptionBlock == null) {
+ fOptionBlock = new ManagedBuildOptionBlock(this);
+ }
+ }
+
+ protected Control createContents(Composite parent) {
+ GridData gd;
+
+// Create the container we return to the property page editor
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setFont(parent.getFont());
+ GridLayout compositeLayout = new GridLayout();
+ compositeLayout.numColumns = 1;
+ compositeLayout.marginHeight = 0;
+ compositeLayout.marginWidth = 0;
+ composite.setLayout( compositeLayout );
+
+// Initialize the key data
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
+ if (info.getVersion() == null) {
+ // Display a message page instead of the properties control
+ final Label invalidInfo = new Label(composite, SWT.LEFT);
+ invalidInfo.setFont(composite.getFont());
+ invalidInfo.setText(ManagedBuilderUIMessages.getResourceString("ResourceBuildPropertyPage.error.version_low")); //$NON-NLS-1$
+ invalidInfo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING,GridData.VERTICAL_ALIGN_CENTER, true, true));
+ return composite;
+ }
+
+ // Add a config selection area
+ Group configGroup = ControlFactory.createGroup(composite, ManagedBuilderUIMessages.getResourceString(ACTIVE_RESOURCE_LABEL), 1);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.grabExcessHorizontalSpace = true;
+ configGroup.setLayoutData(gd);
+ // Use the form layout inside the group composite
+ FormLayout form = new FormLayout();
+ form.marginHeight = 5;
+ form.marginWidth = 5;
+ configGroup.setLayout(form);
+
+ excludedCheckBox = ControlFactory.createCheckBox(configGroup, ManagedBuilderUIMessages.getResourceString(EXCLUDE_CHECKBOX));
+ excludedCheckBox.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ handleIsExcluded();
+ }
+ });
+ excludedCheckBox.setToolTipText(ManagedBuilderUIMessages.getResourceString(EXCLUDE_TIP));
+
+ FormData fd = new FormData();
+ fd = new FormData();
+ fd.left = new FormAttachment(excludedCheckBox, 0, SWT.CENTER);
+ excludedCheckBox.setLayoutData(fd);
+
+ Label configLabel = ControlFactory.createLabel(configGroup, ManagedBuilderUIMessages.getResourceString(CONFIG_LABEL));
+ configSelector = new Combo(configGroup, SWT.READ_ONLY | SWT.DROP_DOWN);
+ configSelector.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ handleConfigSelection();
+ }
+ });
+ configSelector.setToolTipText(ManagedBuilderUIMessages.getResourceString(CONF_TIP));
+
+ // Now do the form layout for the widgets
+
+ fd = new FormData();
+ fd.top = new FormAttachment(excludedCheckBox, 15, SWT.DEFAULT);
+
+ configLabel.setLayoutData(fd);
+
+ fd = new FormData();
+ fd.top = new FormAttachment(excludedCheckBox, 15, SWT.DEFAULT);
+ fd.left = new FormAttachment(configLabel, 5, SWT.DEFAULT);
+ fd.right = new FormAttachment(80, -20);
+ configSelector.setLayoutData(fd);
+
+// Create the Tools Settings, Build Settings, ... Tabbed pane
+ Group tabGroup = ControlFactory.createGroup(composite, ManagedBuilderUIMessages.getResourceString(RESOURCE_SETTINGS_LABEL), 1);
+ gd = new GridData(GridData.FILL_BOTH);
+ tabGroup.setLayoutData(gd);
+ fOptionBlock.createContents(tabGroup, getElement());
+
+// Update the contents of the configuration widget
+ populateConfigurations();
+ WorkbenchHelp.setHelp(composite,ManagedBuilderHelpContextIds.MAN_PROJ_BUILD_PROP);
+ return composite;
+ }
+
+ private void handleIsExcluded() {
+
+ // Check whether the check box is selected or not.
+ boolean isSelected = excludedCheckBox.getSelection();
+ setExcluded(isSelected);
+ }
+
+ /*
+ * (non-Javadoc) @return an array of names for the configurations defined
+ * for the chosen
+ */
+ private String[] getConfigurationNames() {
+ String[] names = new String[configurations.length];
+ for (int index = 0; index < configurations.length; ++index) {
+ names[index] = configurations[index].getName();
+ }
+ return names;
+ }
+
+ protected Point getLastShellSize() {
+ if (lastShellSize == null) {
+ Shell shell = getShell();
+ if (shell != null)
+ lastShellSize = shell.getSize();
+ }
+ return lastShellSize;
+ }
+
+ public IProject getProject() {
+ Object element = getElement();
+ if (element != null && element instanceof IFile) {
+ IFile file = (IFile) element;
+ return (IProject) file.getProject();
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc) @return
+ */
+ public IConfiguration getSelectedConfiguration() {
+ return selectedConfiguration;
+ }
+
+ /*
+ * Event Handlers
+ */
+ private void handleConfigSelection() {
+ // If there is nothing in config selection widget just bail
+ if (configSelector.getItemCount() == 0)
+ return;
+
+ // Check if the user has selected the "all" configuration
+ int selectionIndex = configSelector.getSelectionIndex();
+ if (selectionIndex == -1)
+ return;
+ String configName = configSelector.getItem(selectionIndex);
+ if (configName.equals(ManagedBuilderUIMessages
+ .getResourceString(ALL_CONFS))) {
+ // This is the all config
+ return;
+ } else {
+ IConfiguration newConfig = configurations[selectionIndex];
+ if (newConfig != selectedConfiguration) {
+ // If the user has changed values, and is now switching configurations, prompt for saving
+ if (selectedConfiguration != null) {
+ if (fOptionBlock.isDirty()) {
+ Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
+ boolean shouldApply = MessageDialog.openQuestion(shell,
+ ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.changes.save.title"), //$NON-NLS-1$
+ ManagedBuilderUIMessages.getFormattedString("BuildPropertyPage.changes.save.question", //$NON-NLS-1$
+ new String[] {selectedConfiguration.getName(), newConfig.getName()}));
+ if (shouldApply) {
+ if (performOk()) {
+ fOptionBlock.setDirty(false);
+ } else {
+ MessageDialog.openWarning(shell,
+ ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.changes.save.title"), //$NON-NLS-1$
+ ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.changes.save.error")); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ // Set the new selected configuration
+ selectedConfiguration = newConfig;
+ ManagedBuildManager.setSelectedConfiguration(getProject(), selectedConfiguration);
+ // Set the current Resource Configuration
+ setCurrentResourceConfig(findCurrentResourceConfig());
+
+ isExcluded = getCurrentResourceConfig().isExcluded();
+ fOptionBlock.updateValues();
+ excludedCheckBox.setSelection(isExcluded);
+ }
+ }
+ return;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+ */
+
+
+ protected void performDefaults() {
+ fOptionBlock.performDefaults();
+ excludedCheckBox.setSelection(getCurrentResourceConfig().isExcluded());
+ super.performDefaults();
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+ */
+ public boolean performOk() {
+
+ // If the user did not visit this page, then there is nothing to do.
+ if (!displayedConfig) return true;
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ fOptionBlock.performApply(monitor);
+ }
+ };
+ IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
+ try {
+ new ProgressMonitorDialog(getShell()).run(false, true, op);
+ } catch (InvocationTargetException e) {
+ Throwable e1 = e.getTargetException();
+ ManagedBuilderUIPlugin.errorDialog(getShell(), ManagedBuilderUIMessages.getResourceString("ManagedProjectPropertyPage.internalError"),e1.toString(), e1); //$NON-NLS-1$
+ return false;
+ } catch (InterruptedException e) {
+ // cancelled
+ return false;
+ }
+
+ // Write out the build model info
+ ManagedBuildManager.setDefaultConfiguration(getProject(), getSelectedConfiguration());
+ if ( getCurrentResourceConfig().isExcluded() != isExcluded() ) {
+ getCurrentResourceConfig().setExclude(isExcluded());
+ selectedConfiguration.setRebuildState(true);
+ }
+
+ ManagedBuildManager.saveBuildInfo(getProject(), false);
+ return true;
+ }
+
+ private void populateConfigurations() {
+
+ ManagedBuildManager.setSelectedConfiguration(getProject(), selectedConfiguration);
+ // If the config select widget is not there yet, just stop
+ if (configSelector == null)
+ return;
+
+ // Find the configurations defined for the platform
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
+ configurations = info.getManagedProject().getConfigurations();
+ if (configurations.length == 0)
+ return;
+
+ // Clear and replace the contents of the selector widget
+ configSelector.removeAll();
+ configSelector.setItems(getConfigurationNames());
+
+ // Make sure the active configuration is selected
+ IConfiguration defaultConfig = info.getDefaultConfiguration();
+ int index = configSelector.indexOf(defaultConfig.getName());
+ configSelector.select(index == -1 ? 0 : index);
+ handleConfigSelection();
+
+ }
+
+
+ /**
+ * @return Returns the currentResourceConfig.
+ */
+ public IResourceConfiguration getCurrentResourceConfig() {
+ return currentResourceConfig;
+ }
+
+ /**
+ * @param currentResourceConfig
+ * The currentResourceConfig to set.
+ */
+ public void setCurrentResourceConfig(
+ IResourceConfiguration currentResourceConfig) {
+ if (currentResourceConfig != null)
+ this.currentResourceConfig = currentResourceConfig;
+ else {
+ IFile file = (IFile) getElement();
+
+ // create a new resource configuration for this resource.
+ this.currentResourceConfig = selectedConfiguration.createResourceConfiguration(file);
+ }
+ }
+
+ // Check whether a resource configuration already exists for the current
+ // resource in selectedConfiguration.
+ // if so, return the resource configuration, otherwise return null.
+
+ public IResourceConfiguration findCurrentResourceConfig() {
+
+ IResourceConfiguration resConfigElement = null;
+
+ // Check if the selected configuration has any resourceConfigurations.
+ if (selectedConfiguration.getResourceConfigurations().length == 0)
+ return null;
+
+ IResourceConfiguration[] resourceConfigurations = selectedConfiguration
+ .getResourceConfigurations();
+ IFile file = (IFile) getElement();
+
+ // Check whether a resource configuration is already exists for the
+ // selected file.
+ for (int i = 0; i < resourceConfigurations.length; i++) {
+ resConfigElement = resourceConfigurations[i];
+ if (file.getFullPath().toString().equals(
+ resConfigElement.getResourcePath())) {
+ return resConfigElement;
+ }
+ }
+
+ return null;
+ }
+ /**
+ * @see org.eclipse.jface.preference.IPreferencePageContainer#updateButtons()
+ */
+ public void updateButtons() {
+ }
+ /**
+ * @see org.eclipse.jface.preference.IPreferencePageContainer#updateMessage()
+ */
+ public void updateMessage() {
+ }
+ /**
+ * @see org.eclipse.jface.preference.IPreferencePageContainer#updateTitle()
+ */
+ public void updateTitle() {
+ }
+
+ public void updateContainer() {
+ fOptionBlock.update();
+ setValid(fOptionBlock.isValid());
+ setErrorMessage(fOptionBlock.getErrorMessage());
+ }
+
+ public boolean isValid() {
+ updateContainer();
+ return super.isValid();
+ }
+
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ fOptionBlock.setVisible(visible);
+ if (visible) {
+ fOptionBlock.updateValues();
+ displayedConfig = true;
+ }
+ }
+
+ public IPreferenceStore getPreferenceStore()
+ {
+ return fOptionBlock.getPreferenceStore();
+ }
+
+ /* (non-Javadoc)
+ * Return the IPreferenceStore of the Tool Settings block
+ */
+ public IPreferenceStore getToolSettingsPreferenceStore()
+ {
+ return fOptionBlock.getToolSettingsPreferenceStore();
+ }
+ public Preferences getPreferences()
+ {
+ return null;
+ }
+ public void enableConfigSelection (boolean enable) {
+ configSelector.setEnabled(enable);
+ }
+ /**
+ * @return Returns the isExcluded.
+ */
+ public boolean isExcluded() {
+ return isExcluded;
+ }
+ /**
+ * @param isExcluded The isExcluded to set.
+ */
+ public void setExcluded(boolean isExcluded) {
+ this.isExcluded = isExcluded;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java
index 88acea5bb02..f67a93c39e2 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * Copyright (c) 2002,2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -11,16 +9,22 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
* Timesys - Initial API and implementation
* IBM Rational Software
* *********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.properties;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
public class ToolListContentProvider implements ITreeContentProvider{
+ public static final int FILE = 0x1;
+ public static final int PROJECT = 0x4;
private static Object[] EMPTY_ARRAY = new Object[0];
- private IConfiguration root;
+ private IConfiguration configRoot;
+ private IResourceConfiguration resConfigRoot;
+ private int elementType;
/**
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
@@ -28,6 +32,9 @@ public class ToolListContentProvider implements ITreeContentProvider{
public void dispose() {
}
+ public ToolListContentProvider(int elementType) {
+ this.elementType = elementType;
+ }
/**
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
*/
@@ -36,7 +43,11 @@ public class ToolListContentProvider implements ITreeContentProvider{
if (parentElement instanceof IConfiguration) {
IConfiguration config = (IConfiguration)parentElement;
// the categories are all accessed through the tools
- return config.getTools();
+ return config.getFilteredTools();
+ } else if( parentElement instanceof IResourceConfiguration) {
+ // If parent is a resource configuration, return a list of its tools
+ IResourceConfiguration resConfig = (IResourceConfiguration)parentElement;
+ return resConfig.getTools();
} else if (parentElement instanceof ITool) {
// If this is a tool, return the categories it contains
ITool tool = (ITool)parentElement;
@@ -67,7 +78,10 @@ public class ToolListContentProvider implements ITreeContentProvider{
IOptionCategory parent = cat.getOwner();
// Then we need to get the configuration we belong to
if (parent == null) {
- return root;
+ if(elementType == FILE)
+ return resConfigRoot;
+ else
+ return configRoot;
}
return parent;
}
@@ -85,7 +99,14 @@ public class ToolListContentProvider implements ITreeContentProvider{
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- root = (IConfiguration) newInput;
+ if(elementType == FILE) {
+ resConfigRoot = (IResourceConfiguration)newInput;
+ configRoot = null;
+ }
+ else if(elementType == PROJECT) {
+ configRoot = (IConfiguration) newInput;
+ resConfigRoot = null;
+ }
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListLabelProvider.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListLabelProvider.java
index b2f85d94b27..e9d00a093d0 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListLabelProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListLabelProvider.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * Copyright (c) 2002,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,6 +8,7 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
* Contributors:
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.properties;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.ITool;
@@ -18,7 +17,7 @@ import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
-class ToolListLabelProvider extends LabelProvider {
+public class ToolListLabelProvider extends LabelProvider {
private final Image IMG_TOOL = ManagedBuilderUIImages.get(ManagedBuilderUIImages.IMG_BUILD_TOOL);
private final Image IMG_CAT = ManagedBuilderUIImages.get(ManagedBuilderUIImages.IMG_BUILD_CAT);
private static final String TREE_LABEL = "BuildPropertyPage.label.ToolTree"; //$NON-NLS-1$
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java
index 950908890d4..2f47bf7a7db 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.wizards;
-
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * Copyright (c) 2002,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,14 +8,16 @@ package org.eclipse.cdt.managedbuilder.ui.wizards;
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ListIterator;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
@@ -45,7 +45,7 @@ import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.help.WorkbenchHelp;
/**
- * Class that implements the target and configuration selection page in the new
+ * Class that implements the project type and configuration selection page in the new
* project wizard for managed builder projects.
*
* @since 1.2
@@ -65,11 +65,11 @@ public class CProjectPlatformPage extends WizardPage {
protected NewManagedProjectWizard parentWizard;
protected Combo platformSelection;
private ArrayList selectedConfigurations;
- protected ITarget selectedTarget;
+ protected IProjectType selectedProjectType;
protected Button showAll;
protected CheckboxTableViewer tableViewer;
- protected String[] targetNames;
- protected ArrayList targets;
+ protected String[] projectTypeNames;
+ protected ArrayList projectTypes;
/**
* Constructor.
@@ -79,7 +79,7 @@ public class CProjectPlatformPage extends WizardPage {
public CProjectPlatformPage(String pageName, NewManagedProjectWizard parentWizard) {
super(pageName);
setPageComplete(false);
- selectedTarget = null;
+ selectedProjectType = null;
selectedConfigurations = new ArrayList(0);
this.parentWizard = parentWizard;
}
@@ -141,14 +141,14 @@ public class CProjectPlatformPage extends WizardPage {
WorkbenchHelp.setHelp(composite, ManagedBuilderHelpContextIds.MAN_PROJ_PLATFORM_HELP);
// Create the widgets
- createTargetSelectGroup(composite);
+ createTypeSelectGroup(composite);
createConfigSelectionGroup(composite);
createShowAllGroup(composite);
- // Select the first target in the list
- populateTargets();
+ // Select the first project type in the list
+ populateTypes();
platformSelection.select(0);
- handleTargetSelection();
+ handleTypeSelection();
// Do the nasty
setErrorMessage(null);
@@ -168,9 +168,9 @@ public class CProjectPlatformPage extends WizardPage {
showAll.setText(ManagedBuilderUIMessages.getResourceString(SHOWALL_LABEL));
showAll.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
- populateTargets();
+ populateTypes();
platformSelection.select(0);
- handleTargetSelection();
+ handleTypeSelection();
}
});
showAll.addDisposeListener(new DisposeListener() {
@@ -180,7 +180,7 @@ public class CProjectPlatformPage extends WizardPage {
});
}
- private void createTargetSelectGroup(Composite parent) {
+ private void createTypeSelectGroup(Composite parent) {
// Create the group composite
Composite composite = new Composite(parent, SWT.NULL);
composite.setFont(parent.getFont());
@@ -197,7 +197,7 @@ public class CProjectPlatformPage extends WizardPage {
platformSelection.setToolTipText(ManagedBuilderUIMessages.getResourceString(TARGET_TIP));
platformSelection.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
- handleTargetSelection();
+ handleTypeSelection();
}
});
platformSelection.addDisposeListener(new DisposeListener() {
@@ -227,13 +227,13 @@ public class CProjectPlatformPage extends WizardPage {
}
/**
- * Returns the name of the selected platform.
+ * Returns the selected project type.
*
- * @return String containing platform name or <code>null</code> if an invalid selection
+ * @return IProjectType Selected type or <code>null</code> if an invalid selection
* has been made.
*/
- public ITarget getSelectedTarget() {
- return selectedTarget;
+ public IProjectType getSelectedProjectType() {
+ return selectedProjectType;
}
private void handleConfigurationSelectionChange() {
@@ -250,16 +250,16 @@ public class CProjectPlatformPage extends WizardPage {
* @return <code>true</code> if all controls are valid, and
* <code>false</code> if at least one is invalid
*/
- protected void handleTargetSelection() {
+ protected void handleTypeSelection() {
/*
- * The index in the combo is the offset into the target list
+ * The index in the combo is the offset into the project type list
*/
int index;
if (platformSelection != null
&& (index = platformSelection.getSelectionIndex()) != -1) {
- if (selectedTarget != (ITarget) targets.get(index)) {
- selectedTarget = (ITarget) targets.get(index);
- parentWizard.updateTargetProperties();
+ if (selectedProjectType != (IProjectType) projectTypes.get(index)) {
+ selectedProjectType = (IProjectType) projectTypes.get(index);
+ parentWizard.updateProjectTypeProperties();
}
}
populateConfigurations();
@@ -271,59 +271,66 @@ public class CProjectPlatformPage extends WizardPage {
* By default, all the configurations are selected.
*/
private void populateConfigurations() {
- // Make the root of the content provider the new target
- tableViewer.setInput(selectedTarget);
+ // Make the root of the content provider the new project type
+ tableViewer.setInput(selectedProjectType);
tableViewer.setAllChecked(true);
handleConfigurationSelectionChange();
}
/* (non-Javadoc)
- * Extracts the names from the targets that are valid for the wizard
+ * Extracts the names from the project types that are valid for the wizard
* session and populates the combo widget with them.
*/
- private void populateTargetNames() {
- targetNames = new String[targets.size()];
- ListIterator iter = targets.listIterator();
+ private void populateTypeNames() {
+ projectTypeNames = new String[projectTypes.size()];
+ ListIterator iter = projectTypes.listIterator();
int index = 0;
while (iter.hasNext()) {
- targetNames[index++] = ((ITarget) iter.next()).getName();
+ projectTypeNames[index++] = ((IProjectType) iter.next()).getName();
}
// Now setup the combo
platformSelection.removeAll();
- platformSelection.setItems(targetNames);
+ platformSelection.setItems(projectTypeNames);
}
/* (non-Javadoc)
- * Collects all the valid targets for the platform Eclipse is running on
+ * Collects all the valid project types for the platform Eclipse is running on
*/
- private void populateTargets() {
+ private void populateTypes() {
// Get a list of platforms defined by plugins
- ITarget[] allTargets = ManagedBuildManager.getDefinedTargets(null);
- targets = new ArrayList();
+ IProjectType[] allProjectTypes = ManagedBuildManager.getDefinedProjectTypes();
+ projectTypes = new ArrayList();
String os = Platform.getOS();
String arch = Platform.getOSArch();
- // Add all of the concrete targets to the target list
- for (int index = 0; index < allTargets.length; ++index) {
- ITarget target = allTargets[index];
- if (!target.isAbstract() && !target.isTestTarget()) {
+ // Add all of the concrete project types to the list
+ for (int index = 0; index < allProjectTypes.length; ++index) {
+ IProjectType type = allProjectTypes[index];
+ if (!type.isAbstract() && !type.isTestProjectType()) {
// If the check box is selected show all the targets
if (showAll != null && showAll.getSelection() == true) {
- targets.add(target);
+ projectTypes.add(type);
} else {
// Apply the OS and ARCH filters to determine if the target should be shown
- List targetOSList = Arrays.asList(target.getTargetOSList());
- if (targetOSList.contains("all") || targetOSList.contains(os)) { //$NON-NLS-1$
- List targetArchList = Arrays.asList(target.getTargetArchList());
- if (targetArchList.contains("all") || targetArchList.contains(arch)) { //$NON-NLS-1$
- targets.add(target);
+ // Determine if the project type has any configuration with a tool-chain
+ // that supports this OS & Architecture.
+ IConfiguration[] configs = type.getConfigurations();
+ for (int j = 0; j < configs.length; ++j) {
+ IToolChain tc = configs[j].getToolChain();
+ List osList = Arrays.asList(tc.getOSList());
+ if (osList.contains("all") || osList.contains(os)) { //$NON-NLS-1$
+ List archList = Arrays.asList(tc.getArchList());
+ if (archList.contains("all") || archList.contains(arch)) { //$NON-NLS-1$
+ projectTypes.add(type);
+ break;
+ }
}
}
}
}
}
- targets.trimToSize();
- populateTargetNames();
+ projectTypes.trimToSize();
+ populateTypeNames();
}
/**
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ConfigurationContentProvider.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ConfigurationContentProvider.java
index 27db61034bd..c800b9f43c1 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ConfigurationContentProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ConfigurationContentProvider.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.wizards;
-
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * Copyright (c) 2002,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,9 +8,10 @@ package org.eclipse.cdt.managedbuilder.ui.wizards;
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
@@ -20,7 +19,7 @@ public class ConfigurationContentProvider implements IStructuredContentProvider
// The contents of the parent of the table is a list of configurations
public Object[] getElements(Object parent) {
// The content is a list of configurations
- IConfiguration[] configs = ((ITarget) parent).getConfigurations();
+ IConfiguration[] configs = ((IProjectType) parent).getConfigurations();
return (configs.length == 0) ? new Object[0] : configs;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java
index c2198773196..35cc4d7397a 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.wizards;
-
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * Copyright (c) 2002,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,6 +8,7 @@ package org.eclipse.cdt.managedbuilder.ui.wizards;
* Contributors:
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
import java.util.Iterator;
import java.util.List;
@@ -43,7 +42,7 @@ public class NewManagedProjectOptionPage extends NewCProjectWizardOptionPage {
parent = parentPage;
}
- public void updateTargetProperties() {
+ public void updateProjectTypeProperties() {
// Update the error parser list
if (errorParsers != null) {
errorParsers.updateValues();
@@ -55,8 +54,13 @@ public class NewManagedProjectOptionPage extends NewCProjectWizardOptionPage {
*/
protected void addTabs() {
addTab(new ReferenceBlock());
- errorParsers = new ErrorParserBlock();
- addTab(errorParsers);
+ // NOTE: The setting of error parsers is commented out here
+ // because they need to be set per-configuration.
+ // The other tabs on this page are per-project.
+ // Error parsers can be selected per configuration in the
+ // project properties
+ //errorParsers = new ErrorParserBlock();
+ //addTab(errorParsers);
addTab(indexBlock = new IndexerBlock());
}
@@ -112,9 +116,9 @@ public class NewManagedProjectOptionPage extends NewCProjectWizardOptionPage {
return ManagedBuilderUIPlugin.getDefault().getPluginPreferences();
}
- public void updateTargetProperties() {
+ public void updateProjectTypeProperties() {
// Update the error parser list
- optionBlock.updateTargetProperties();
+ optionBlock.updateProjectTypeProperties();
}
public void setupHelpContextIds(){
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java
index 2fa2b165860..3ca45f48be2 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.wizards;
-
/**********************************************************************
- * Copyright (c) 2002,2004 Rational Software Corporation and others.
+ * Copyright (c) 2002,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,14 +8,16 @@ package org.eclipse.cdt.managedbuilder.ui.wizards;
* Contributors:
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
-
-import java.util.Random;
+package org.eclipse.cdt.managedbuilder.ui.wizards;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
@@ -55,7 +55,7 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
protected static final String SETTINGS_DESC = "MngMakeWizardSettings.description"; //$NON-NLS-1$
// Wizard pages
- protected CProjectPlatformPage targetConfigurationPage;
+ protected CProjectPlatformPage projectConfigurationPage;
protected NewManagedProjectOptionPage optionPage;
public NewManagedProjectWizard() {
@@ -71,10 +71,10 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
super.addPages();
// Add the configuration selection page
- targetConfigurationPage = new CProjectPlatformPage(PREFIX, this);
- targetConfigurationPage.setTitle(ManagedBuilderUIMessages.getResourceString(CONF_TITLE));
- targetConfigurationPage.setDescription(ManagedBuilderUIMessages.getResourceString(CONF_DESC));
- addPage(targetConfigurationPage);
+ projectConfigurationPage = new CProjectPlatformPage(PREFIX, this);
+ projectConfigurationPage.setTitle(ManagedBuilderUIMessages.getResourceString(CONF_TITLE));
+ projectConfigurationPage.setDescription(ManagedBuilderUIMessages.getResourceString(CONF_DESC));
+ addPage(projectConfigurationPage);
// Add the options (tabbed) page
optionPage = new NewManagedProjectOptionPage(PREFIX, this);
@@ -97,9 +97,9 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
optionPage.setupHelpContextIds();
}
}
- public void updateTargetProperties() {
+ public void updateProjectTypeProperties() {
// Update the error parser list
- optionPage.updateTargetProperties();
+ optionPage.updateProjectTypeProperties();
}
protected void doRun(IProgressMonitor monitor) throws CoreException {
@@ -120,40 +120,42 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
ManagedBuilderUIPlugin.log(e);
}
- // Add the target to the project
- ITarget newTarget = null;
+ // Add the ManagedProject to the project
+ IManagedProject newManagedProject = null;
try {
ManagedBuildManager.createBuildInfo(newProject);
- ITarget parent = targetConfigurationPage.getSelectedTarget();
- newTarget = ManagedBuildManager.createTarget(newProject, parent);
- if (newTarget != null) {
- ICDescriptor desc = null;
- try {
- desc = CCorePlugin.getDefault().getCProjectDescription(newProject, true);
- desc.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, ManagedBuildManager.INTERFACE_IDENTITY);
- desc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, newTarget.getBinaryParserId());
- } catch (CoreException e) {
- ManagedBuilderUIPlugin.log(e);
- }
- newTarget.setArtifactName(getBuildGoalName());
- IConfiguration [] selectedConfigs = targetConfigurationPage.getSelectedConfigurations();
- Random r = new Random();
- r.setSeed(System.currentTimeMillis());
+ IProjectType parent = projectConfigurationPage.getSelectedProjectType();
+ newManagedProject = ManagedBuildManager.createManagedProject(newProject, parent);
+ if (newManagedProject != null) {
+ IConfiguration [] selectedConfigs = projectConfigurationPage.getSelectedConfigurations();
for (int i = 0; i < selectedConfigs.length; i++) {
IConfiguration config = selectedConfigs[i];
- int id = r.nextInt();
- if (id < 0) {
- id *= -1;
- }
- newTarget.createConfiguration(config, config.getId() + "." + id); //$NON-NLS-1$
+ int id = ManagedBuildManager.getRandomNumber();
+ IConfiguration newConfig = newManagedProject.createConfiguration(config, config.getId() + "." + id); //$NON-NLS-1$
+ newConfig.setArtifactName(newManagedProject.getDefaultArtifactName());
}
// Now add the first config in the list as the default
- IConfiguration[] newConfigs = newTarget.getConfigurations();
+ IConfiguration[] newConfigs = newManagedProject.getConfigurations();
if (newConfigs.length > 0) {
ManagedBuildManager.setDefaultConfiguration(newProject, newConfigs[0]);
+ ManagedBuildManager.setSelectedConfiguration(newProject, newConfigs[0]);
}
- ManagedBuildManager.setSelectedTarget(newProject, newTarget);
ManagedBuildManager.setNewProjectVersion(newProject);
+ ICDescriptor desc = null;
+ try {
+ desc = CCorePlugin.getDefault().getCProjectDescription(newProject, true);
+ desc.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, ManagedBuildManager.INTERFACE_IDENTITY);
+ // TODO: The binary parser setting is currently per-project in the rest of CDT.
+ // In the MBS, it is per-coonfiguration. For now, select the binary parser of the
+ // first configuration.
+ if (newConfigs.length > 0) {
+ IToolChain tc = newConfigs[0].getToolChain();
+ ITargetPlatform targetPlatform = tc.getTargetPlatform();
+ desc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, targetPlatform.getBinaryParserId());
+ }
+ } catch (CoreException e) {
+ ManagedBuilderUIPlugin.log(e);
+ }
}
} catch (BuildException e) {
ManagedBuilderUIPlugin.log(e);
@@ -170,19 +172,6 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
monitor.done();
}
- /**
- * @return
- */
- private String getBuildGoalName() {
- String name = new String();
- // Check for spaces
- String[] tokens = newProject.getName().split("\\s"); //$NON-NLS-1$
- for (int index = 0; index < tokens.length; ++index) {
- name += tokens[index];
- }
- return name;
- }
-
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunPrologue(org.eclipse.core.runtime.IProgressMonitor)
*/
@@ -211,8 +200,8 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
return ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID;
}
- public ITarget getSelectedTarget() {
- return targetConfigurationPage.getSelectedTarget();
+ public IProjectType getSelectedProjectType() {
+ return projectConfigurationPage.getSelectedProjectType();
}
}

Back to the top