Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Hirsl2005-01-24 18:49:34 +0000
committerVladimir Hirsl2005-01-24 18:49:34 +0000
commit66d9c39ea67f6e1a47769ba30254a6560a7ef4f3 (patch)
tree1256a4581e8ea431cb1905e6bf2b8d4f9a1913f1 /build/org.eclipse.cdt.make.ui
parente7a9587ad8cc3d788a60034af5fd95ea78a1d1bb (diff)
downloadorg.eclipse.cdt-66d9c39ea67f6e1a47769ba30254a6560a7ef4f3.tar.gz
org.eclipse.cdt-66d9c39ea67f6e1a47769ba30254a6560a7ef4f3.tar.xz
org.eclipse.cdt-66d9c39ea67f6e1a47769ba30254a6560a7ef4f3.zip
New Scanner Config Discovery 'framework' in preparation for per file SC discovery. Currently implemented: Per project profiles for standard make and managed builders.
Diffstat (limited to 'build/org.eclipse.cdt.make.ui')
-rw-r--r--build/org.eclipse.cdt.make.ui/plugin.properties2
-rw-r--r--build/org.eclipse.cdt.make.ui/plugin.xml8
-rw-r--r--build/org.eclipse.cdt.make.ui/schema/DiscoveryProfilePage.exsd129
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties52
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryOptionsBlock.java199
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryPage.java141
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildPathInfoBlock.java489
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveredPathContainerPage.java23
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveryOptionsBlock.java882
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerProjectSCDProfilePage.java364
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/ManageDefinedSymbolsDialog.java537
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/ManageIncludePathsDialog.java598
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/ScannerConfigOptionsDialog.java576
13 files changed, 1190 insertions, 2810 deletions
diff --git a/build/org.eclipse.cdt.make.ui/plugin.properties b/build/org.eclipse.cdt.make.ui/plugin.properties
index b867bd2c3d4..265d5518376 100644
--- a/build/org.eclipse.cdt.make.ui/plugin.properties
+++ b/build/org.eclipse.cdt.make.ui/plugin.properties
@@ -67,3 +67,5 @@ IncludeSymbolProperties.name=C/C++ Include Paths & Symbols
ProjectPathProperties.name=C/C++ Project Paths
DiscoveredScannerInfoContainer.name=Discovered scanner configuration container
+
+GCCPerProjectProfile.name=GCC per project scanner info profile
diff --git a/build/org.eclipse.cdt.make.ui/plugin.xml b/build/org.eclipse.cdt.make.ui/plugin.xml
index 39ea34e91c2..c779593c414 100644
--- a/build/org.eclipse.cdt.make.ui/plugin.xml
+++ b/build/org.eclipse.cdt.make.ui/plugin.xml
@@ -25,6 +25,7 @@
<import plugin="org.eclipse.cdt.make.core"/>
<import plugin="org.eclipse.core.runtime"/>
</requires>
+ <extension-point id="DiscoveryProfilePage" name="%discoveryProfilePage.name" schema="schema/DiscoveryProfilePage.exsd"/>
<extension
@@ -526,4 +527,11 @@
<extension
point="org.eclipse.core.runtime.preferences">
<initializer class="org.eclipse.cdt.make.internal.ui.MakeUIPreferenceInitializer"/>
+ </extension>
+ <extension
+ point="org.eclipse.cdt.make.ui.DiscoveryProfilePage">
+ <profilePage
+ class="org.eclipse.cdt.make.ui.dialogs.GCCPerProjectSCDProfilePage"
+ name="%GCCPerProjectProfile.name"
+ profileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
</extension></plugin>
diff --git a/build/org.eclipse.cdt.make.ui/schema/DiscoveryProfilePage.exsd b/build/org.eclipse.cdt.make.ui/schema/DiscoveryProfilePage.exsd
new file mode 100644
index 00000000000..43c9b8871d9
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/schema/DiscoveryProfilePage.exsd
@@ -0,0 +1,129 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.make.ui">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.make.ui" id="DiscoveryProfilePage" name="Scanner configuration discovery profile options page"/>
+ </appInfo>
+ <documentation>
+ A
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <documentation>
+ An extension to define implementation of a SCD profile options page.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="profilePage" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="profilePage">
+ <annotation>
+ <documentation>
+ Element defines a class that implements SCD profile options page for a profile with specified id.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+ Page name.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="profileId" type="string" use="required">
+ <annotation>
+ <documentation>
+ Associated profile id.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ A class that extends &lt;samp&gt;AbstractDiscoveryPage&lt;/samp&gt; abstract class.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryPage"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties
index 05110ba3521..70bacd27e84 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties
@@ -70,34 +70,6 @@ ErrorParserBlock.label.missingBuilderInformation=Builder is missing or disabled
BuildTarget.target.group_label=Make Target
BuildTarget.target.label=Make Target:
-
-# String constants for the build include path and preprocessor symbols
-BuildPathInfoBlock.label=Paths and Symbols
-BuildPathInfoBlock.paths=Include paths:
-BuildPathInfoBlock.symbols=Defined symbols:
-BuildPathInfoBlock.browse.path=New Include Path
-BuildPathInfoBlock.browse.path.edit=Edit Include Path
-BuildPathInfoBlock.browse.path.label=Path:
-BuildPathInfoBlock.browse.symbol=New Defined Symbol
-BuildPathInfoBlock.browse.symbol.edit=Edit Defined Symbol
-BuildPathInfoBlock.browse.symbol.label=Symbol:
-BuildPathInfoBlock.scGroup.label=Automated discovery of paths and symbols
-BuildPathInfoBlock.scGroup.enabled.label=Automate discovery of paths and symbols
-BuildPathInfoBlock.scGroup.options.label=Options...
-
-BuildPropertyCommon.label.title=Enter Value
-BuildPropertyCommon.label.new=New...
-BuildPropertyCommon.label.edit=Edit...
-BuildPropertyCommon.label.remove=Remove
-BuildPropertyCommon.label.up=Move Up
-BuildPropertyCommon.label.down=Move Down
-BuildPropertyCommon.label.editVar=Edit
-BuildPropertyCommon.label.addVar=Add
-BuildPropertyCommon.label.message=Value:
-BuildPropertyCommon.label.browse=Browse...
-BuildPropertyCommon.label.configs=Defined configurations:
-BuildPropertyCommon.label.manage=Manage...
-
MakeTargetsPreferencePage.buildTargetInBackground.label=Build make targets in background.
MakeDocumentProvider.exception.createElementInfo=Error creating element.
@@ -245,10 +217,13 @@ ManageDefinedSymbolsDialog.discoveredGroup.title=Discovered symbol definitions
# --- ScannerConfigOptionsDialog ---
ScannerConfigOptionsDialog.title=Discovery Options
ScannerConfigOptionsDialog.description=Set the scanner configuration discovery options for this project
+ScannerConfigOptionsDialog.label.missingBuilderInformation=Builder is missing or disabled on project.
+ScannerConfigOptionsDialog.scGroup.label=Automated discovery of paths and symbols
+ScannerConfigOptionsDialog.scGroup.enabled.label=Automate discovery of paths and symbols
+ScannerConfigOptionsDialog.scGroup.selectedProfile.label=Discovery profile:
ScannerConfigOptionsDialog.siBuilder.parser.group_label=Build output parser options
ScannerConfigOptionsDialog.siBuilder.parser.enable.label=Enable build output parser
ScannerConfigOptionsDialog.siBuilder.parser.label=Make build output parser:
-ScannerConfigOptionsDialog.label.missingBuilderInformation=Builder is missing or disabled on project.
ScannerConfigOptionsDialog.siProvider.cmd.group_label=Generate scanner info command options
ScannerConfigOptionsDialog.siProvider.cmd.enable.label=Enable generate scanner info command
ScannerConfigOptionsDialog.siProvider.cmd.use_default=Use default
@@ -258,6 +233,25 @@ ScannerConfigOptionsDialog.siProvider.cmd.error_message=Must enter a 'generate s
ScannerConfigOptionsDialog.siProblem.group.label=Discovery problem reporting
ScannerConfigOptionsDialog.siProblem.generation.enable.label=Report path detection problems
+ScannerConfigOptionsDialog.title=Discovery Options
+ScannerConfigOptionsDialog.description=Set the scanner configuration discovery options for this project
+ScannerConfigOptionsDialog.scGroup.label=Automated discovery of paths and symbols
+ScannerConfigOptionsDialog.scGroup.enabled.button=Automate discovery of paths and symbols
+ScannerConfigOptionsDialog.scGroup.problemReporting.enabled.button=Report path detection problems
+ScannerConfigOptionsDialog.scGroup.selectedProfile.combo=Discovery profile:
+ScannerConfigOptionsDialog.boProvider.group.label=Discovery profile options
+ScannerConfigOptionsDialog.boProvider.parser.enabled.button=Enable build output scanner info discovery
+ScannerConfigOptionsDialog.boProvider.open.label=Load build output from file
+ScannerConfigOptionsDialog.boProvider.browse.button=Browse...
+ScannerConfigOptionsDialog.boProvider.browse.openFileDialog=Build output file:
+ScannerConfigOptionsDialog.boProvider.load.button=Load
+ScannerConfigOptionsDialog.siProvider.parser.enabled.button=Enable generate scanner info command
+ScannerConfigOptionsDialog.siProvider.command.label=Compiler invocation command
+ScannerConfigOptionsDialog.siProvider.browse.button=Browse...
+ScannerConfigOptionsDialog.siProvider.browse.runCommandDialog='gcc' command:
+ScannerConfigOptionsDialog.siProvider.command.errorMessage=Must enter compiler invocation command
+ScannerConfigOptionsDialog.apply.progressMessage=Setting scanner configuration discovery options...
+
# --- DiscoveredScannerConfigurationContainerPage ---
DiscoveredScannerConfigurationContainerPage.title=Edit container
DiscoveredScannerConfigurationContainerPage.description=Manage discovered scanner configuration
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryOptionsBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryOptionsBlock.java
new file mode 100644
index 00000000000..9f081d561b3
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryOptionsBlock.java
@@ -0,0 +1,199 @@
+/***********************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ ***********************************************************************/
+package org.eclipse.cdt.make.ui.dialogs;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
+import org.eclipse.cdt.ui.dialogs.ICOptionPage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Fremework for loading profile option pages
+ *
+ * @author vhirsl
+ */
+public abstract class AbstractDiscoveryOptionsBlock extends AbstractDiscoveryPage {
+ private Map fProfilePageMap = null;
+
+ // Composite parent provided by the block.
+ private Composite fCompositeParent;
+ private ICOptionPage fCurrentPage;
+
+ /**
+ * Create a profile page only on request
+ *
+ * @author vhirsl
+ */
+ protected static class DiscoveryProfilePageConfiguration {
+
+ ICOptionPage page;
+ IConfigurationElement fElement;
+
+ public DiscoveryProfilePageConfiguration(IConfigurationElement element) {
+ fElement = element;
+ }
+
+ public ICOptionPage getPage() throws CoreException {
+ if (page == null) {
+ page = (ICOptionPage) fElement.createExecutableExtension("class"); //$NON-NLS-1$
+ }
+ return page;
+ }
+ public String getName() {
+ return fElement.getAttribute("name"); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @param title
+ */
+ public AbstractDiscoveryOptionsBlock(String title) {
+ super(title);
+ initializeProfilePageMap();
+ }
+
+ /**
+ * @param title
+ * @param image
+ */
+ public AbstractDiscoveryOptionsBlock(String title, ImageDescriptor image) {
+ super(title, image);
+ initializeProfilePageMap();
+ }
+
+ /**
+ *
+ */
+ private void initializeProfilePageMap() {
+ fProfilePageMap = new HashMap(5);
+
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(MakeUIPlugin.getPluginId(), "DiscoveryProfilePage"); //$NON-NLS-1$
+ IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
+ for (int i = 0; i < infos.length; i++) {
+ if (infos[i].getName().equals("profilePage")) { //$NON-NLS-1$
+ String id = infos[i].getAttribute("profileId"); //$NON-NLS-1$
+ fProfilePageMap.put(id, new DiscoveryProfilePageConfiguration(infos[i]));
+ }
+ }
+ }
+
+ protected Composite getCompositeParent() {
+ return fCompositeParent;
+ }
+
+ protected void setCompositeParent(Composite parent) {
+ fCompositeParent = parent;
+// fCompositeParent.setLayout(new TabFolderLayout());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ if (visible) {
+ handleDiscoveryProfileChanged();
+ }
+ }
+
+ /**
+ * Notification that the user changed the selection of the Binary Parser.
+ */
+ protected void handleDiscoveryProfileChanged() {
+ if (getCompositeParent() == null) {
+ return;
+ }
+ String profileId = getCurrentProfileId();
+ ICOptionPage page = getDiscoveryProfilePage(profileId);
+ if (page != null) {
+ if (page.getControl() == null) {
+ Composite parent = getCompositeParent();
+ page.setContainer(getContainer());
+ page.createControl(parent);
+ parent.layout(true);
+ } else {
+ page.setVisible(false);
+ }
+ page.setVisible(true);
+ }
+ setCurrentPage(page);
+ }
+
+ protected ICOptionPage getCurrentPage() {
+ return fCurrentPage;
+ }
+
+ protected void setCurrentPage(ICOptionPage page) {
+ fCurrentPage = page;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#isValid()
+ */
+ public boolean isValid() {
+ return (getCurrentPage() == null) ? true : getCurrentPage().isValid();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#getErrorMessage()
+ */
+ public String getErrorMessage() {
+ return getCurrentPage().getErrorMessage();
+ }
+
+ protected ICOptionPage getDiscoveryProfilePage(String profileId) {
+ DiscoveryProfilePageConfiguration configElement =
+ (DiscoveryProfilePageConfiguration) fProfilePageMap.get(profileId);
+ if (configElement != null) {
+ try {
+ return configElement.getPage();
+ } catch (CoreException e) {
+ }
+ }
+ return null;
+ }
+
+ protected String getDiscoveryProfileName(String profileId) {
+ DiscoveryProfilePageConfiguration configElement =
+ (DiscoveryProfilePageConfiguration) fProfilePageMap.get(profileId);
+ if (configElement != null) {
+ return configElement.getName();
+ }
+ return null;
+ }
+
+ protected String getDiscoveryProfileId(String profileName) {
+ for (Iterator I = fProfilePageMap.keySet().iterator(); I.hasNext();) {
+ String profileId = (String) I.next();
+ String confProfileName = getDiscoveryProfileName(profileId);
+ if (profileName.equals(confProfileName)) {
+ return profileId;
+ }
+ }
+ return null;
+ }
+
+ protected List getDiscoveryProfileIdList() {
+ return new ArrayList(fProfilePageMap.keySet());
+ }
+
+ protected abstract String getCurrentProfileId();
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryPage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryPage.java
new file mode 100644
index 00000000000..5b7c7074a37
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryPage.java
@@ -0,0 +1,141 @@
+/***********************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ ***********************************************************************/
+package org.eclipse.cdt.make.ui.dialogs;
+
+import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
+import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+/**
+ * TODO Provide description
+ *
+ * @author vhirsl
+ */
+public abstract class AbstractDiscoveryPage extends AbstractCOptionPage {
+
+ private Preferences fPrefs;
+ private IScannerConfigBuilderInfo2 fBuildInfo;
+ private boolean fInitialized = false;
+
+ /**
+ *
+ */
+ public AbstractDiscoveryPage() {
+ super();
+ }
+
+ /**
+ * @param title
+ */
+ public AbstractDiscoveryPage(String title) {
+ super(title);
+ }
+
+ /**
+ * @param title
+ * @param image
+ */
+ public AbstractDiscoveryPage(String title, ImageDescriptor image) {
+ super(title, image);
+ }
+
+ /**
+ * @return Returns the fPrefs.
+ */
+ protected Preferences getPrefs() {
+ return fPrefs;
+ }
+ /**
+ * @return Returns the fBuildInfo.
+ */
+ protected IScannerConfigBuilderInfo2 getBuildInfo() {
+ return fBuildInfo;
+ }
+ /**
+ * @return Returns the fInitialized.
+ */
+ protected boolean isInitialized() {
+ return fInitialized;
+ }
+ /**
+ * @param initialized The fInitialized to set.
+ */
+ protected void setInitialized(boolean initialized) {
+ fInitialized = initialized;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#setContainer(org.eclipse.cdt.ui.dialogs.ICOptionContainer)
+ */
+ public void setContainer(ICOptionContainer container) {
+ super.setContainer(container);
+
+ fPrefs = getContainer().getPreferences();
+ IProject project = getContainer().getProject();
+
+ fInitialized = true;
+ if (project != null) {
+ try {
+ fBuildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project);
+ } catch (CoreException e) {
+ // missing builder information (builder disabled or legacy project)
+ fInitialized = false;
+ fBuildInfo = null;
+ }
+ } else {
+ fBuildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fPrefs, false);
+ }
+ }
+
+ /**
+ * Create build info based on project properties
+ * @param project
+ * @return
+ */
+ protected IScannerConfigBuilderInfo2 createBuildInfo(IProject project) {
+ IScannerConfigBuilderInfo2 bi = null;
+ if (project != null) {
+ try {
+ bi = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project);
+ } catch (CoreException e) {
+ // disabled builder... just log it
+ MakeCorePlugin.log(e);
+ }
+ }
+ else {
+ bi = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fPrefs, false);
+ }
+ return bi;
+ }
+
+ /**
+ * Create build info based on preferences
+ * @return
+ */
+ protected IScannerConfigBuilderInfo2 createBuildInfo() {
+ IScannerConfigBuilderInfo2 bi = null;
+ // Populate with the default values
+ if (getContainer().getProject() != null) {
+ // get the preferences
+ bi = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fPrefs, false);
+ } else {
+ // get the defaults
+ bi = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fPrefs, true);
+ }
+ return bi;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildPathInfoBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildPathInfoBlock.java
deleted file mode 100644
index 1cafa37240a..00000000000
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildPathInfoBlock.java
+++ /dev/null
@@ -1,489 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software 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
- * QNX Software Systems - Move to Make plugin
-***********************************************************************/
-package org.eclipse.cdt.make.ui.dialogs;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.StringTokenizer;
-
-import org.eclipse.cdt.internal.ui.util.SWTUtil;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.core.MakeProjectNature;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigUtil;
-import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
-import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
-import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.dialogs.IInputValidator;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.DirectoryDialog;
-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.ui.help.WorkbenchHelp;
-
-public class BuildPathInfoBlock extends AbstractCOptionPage {
- private static final int PROJECT_LIST_MULTIPLIER = 15;
- private static final int INITIAL_LIST_WIDTH = 60;
-
- private static final String PREF_SYMBOLS = "ScannerSymbols"; //$NON-NLS-1$
- private static final String PREF_INCLUDES = "ScannerIncludes"; //$NON-NLS-1$
- private static final String PREFIX = "BuildPathInfoBlock"; //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
- private static final String PATHS = PREFIX + ".paths"; //$NON-NLS-1$
- private static final String SYMBOLS = PREFIX + ".symbols"; //$NON-NLS-1$
- private static final String MANAGE = "BuildPropertyCommon.label.manage"; //$NON-NLS-1$
- private static final String SC_GROUP_LABEL = PREFIX + ".scGroup.label"; //$NON-NLS-1$
- private static final String SC_ENABLED_LABEL = PREFIX + ".scGroup.enabled.label"; //$NON-NLS-1$
- private static final String SC_OPTIONS_LABEL = PREFIX + ".scGroup.options.label"; //$NON-NLS-1$
- private static final String MISSING_BUILDER_MSG = "ScannerConfigOptionsDialog.label.missingBuilderInformation"; //$NON-NLS-1$
-
- private Button scEnabledButton;
- private Button scOptionsButton;
- private List pathList;
- private List symbolList;
- private Composite pathButtonComp;
- private Button managePathsButton;
- private Composite symbolButtonComp;
- private Button manageSymbolsButton;
-
- private ScannerConfigOptionsDialog scOptionsDialog;
- private ManageIncludePathsDialog manageIncludesDialog;
- private ManageDefinedSymbolsDialog manageSymbolsDialog;
-
- private boolean needsSCNature = false;
-
- /**
- * This class add a "browse" button to the selection to be used for the path
- */
- static class SelectPathInputDialog extends InputDialog {
- public SelectPathInputDialog(Shell parentShell, String dialogTitle, String dialogMessage, String initialValue, IInputValidator validator) {
- super(parentShell, dialogTitle, dialogMessage, initialValue, validator);
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- super.createButtonsForButtonBar(parent);
- Button browse = createButton(parent, 3, MakeUIPlugin.getResourceString("BuildPathInfoBlock.button.browse"), true); //$NON-NLS-1$
- browse.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent ev) {
- DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN);
- String currentName = getText().getText();
- if(currentName != null && currentName.trim().length() != 0) {
- dialog.setFilterPath(currentName);
- }
- String dirname = dialog.open();
- if(dirname != null) {
- getText().setText(dirname);
- }
- }
- });
- }
-
- }
-
- public BuildPathInfoBlock() {
- super(MakeUIPlugin.getResourceString(LABEL));
- setDescription(MakeUIPlugin.getResourceString("BuildPathInfoBlock.description")); //$NON-NLS-1$
- }
-
- private void createPathListButtons(Composite parent) {
- // Create a ManageIncludePathsDialog
- if (manageIncludesDialog == null) {
- manageIncludesDialog = new ManageIncludePathsDialog(getShell(), getContainer());
- }
-
- // Create a composite for the buttons
- pathButtonComp = ControlFactory.createComposite(parent, 1);
- ((GridData) pathButtonComp.getLayoutData()).verticalAlignment = GridData.BEGINNING;
- ((GridData) pathButtonComp.getLayoutData()).grabExcessHorizontalSpace = false;
- pathButtonComp.setFont(parent.getFont());
-
- // Add the buttons
- managePathsButton = ControlFactory.createPushButton(pathButtonComp, MakeUIPlugin.getResourceString(MANAGE));
- managePathsButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleManagePaths();
- }
- });
- managePathsButton.setFont(parent.getFont());
- managePathsButton.setLayoutData(new GridData());
- SWTUtil.setButtonDimensionHint(managePathsButton);
- return;
- }
-
- protected void handleManagePaths() {
- if (manageIncludesDialog.open() == Window.OK) {
- pathList.setItems(manageIncludesDialog.getManagedIncludes());
- }
- }
-
- private void createPathListControl(Composite parent, int numColumns) {
- // Create the list
- pathList = new List(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
-
- // Make it occupy the first 2 columns
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.grabExcessHorizontalSpace = true;
- gd.horizontalSpan = numColumns - 1;
- gd.heightHint = getDefaultFontHeight(pathList, PROJECT_LIST_MULTIPLIER);
- gd.widthHint = convertWidthInCharsToPixels(INITIAL_LIST_WIDTH);
- pathList.setLayoutData(gd);
- pathList.setFont(parent.getFont());
- }
-
- /**
- * Get the defualt widget height for the supplied control.
- * @return int
- * @param control - the control being queried about fonts
- * @param lines - the number of lines to be shown on the table.
- */
- private static int getDefaultFontHeight(Control control, int lines) {
- FontData[] viewerFontData = control.getFont().getFontData();
- int fontHeight = 10;
-
- //If we have no font data use our guess
- if (viewerFontData.length > 0)
- fontHeight = viewerFontData[0].getHeight();
- return lines * fontHeight;
- }
-
- private void createSymbolListButtons(Composite parent) {
- // Create a ManageDefinedSymbolsDialog
- if (manageSymbolsDialog == null) {
- manageSymbolsDialog = new ManageDefinedSymbolsDialog(getShell(), getContainer());
- }
-
- // Create a composite for the buttons
- symbolButtonComp = ControlFactory.createComposite(parent, 1);
- ((GridData) symbolButtonComp.getLayoutData()).verticalAlignment = GridData.BEGINNING;
- ((GridData) symbolButtonComp.getLayoutData()).grabExcessHorizontalSpace = false;
- symbolButtonComp.setFont(parent.getFont());
-
- // Add the Manage button
- manageSymbolsButton = ControlFactory.createPushButton(symbolButtonComp, MakeUIPlugin.getResourceString(MANAGE));
- manageSymbolsButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleManageSymbols();
- }
- });
- manageSymbolsButton.setFont(parent.getFont());
- manageSymbolsButton.setLayoutData(new GridData());
- SWTUtil.setButtonDimensionHint(manageSymbolsButton);
- return;
- }
-
- protected void handleManageSymbols() {
- if (manageSymbolsDialog.open() == Window.OK) {
- symbolList.setItems(manageSymbolsDialog.getManagedSymbols());
- }
- }
-
- private void createSymbolListControl(Composite parent, int numColumns) {
- // Create the list
- symbolList = new List(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
-
- // Make it occupy the first n-1 columns
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.horizontalSpan = numColumns - 1;
- gd.grabExcessHorizontalSpace = true;
- gd.heightHint = getDefaultFontHeight(pathList, PROJECT_LIST_MULTIPLIER);
- gd.widthHint = convertWidthInCharsToPixels(INITIAL_LIST_WIDTH);
- symbolList.setLayoutData(gd);
- symbolList.setFont(parent.getFont());
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.wizards.IWizardTab#doRun(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void performApply(IProgressMonitor monitor) throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- // First store scanner config options
- if (scOptionsDialog.isInitialized()) {
- try {
- scOptionsDialog.performApply(monitor);
- }
- catch (CoreException e) {
- // builder was disabled while scOptionsDialog was initialized
- }
- }
-
- IProject project = getContainer().getProject();
- if (project != null) {
- // Store the paths and symbols
- monitor.beginTask(MakeUIPlugin.getResourceString("BuildPathInfoBlock.monitor.settingScannerInfo"), 3); //$NON-NLS-1$
- IDiscoveredPathInfo info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project);
- boolean changed = manageIncludesDialog.saveTo(info);
- monitor.worked(1);
- changed |= manageSymbolsDialog.saveTo(info);
- monitor.worked(1);
- if (changed) {
- MakeCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(info);
- }
- monitor.done();
- }
- else {
- setIncludes(MakeCorePlugin.getDefault().getPluginPreferences());
- setSymbols(MakeCorePlugin.getDefault().getPluginPreferences());
- }
- }
-
- public void performDefaults() {
- // First restore scanner config options
- scOptionsDialog.performDefaults();
- scEnabledButton.setSelection(scOptionsDialog.isScannerConfigDiscoveryEnabled());
- handleScannerConfigEnable();
-
- pathList.removeAll();
- symbolList.removeAll();
-// if (getContainer().getProject() != null) {
-// pathList.setItems(getIncludes(MakeCorePlugin.getDefault().getPluginPreferences()));
-// symbolList.setItems(getSymbols(MakeCorePlugin.getDefault().getPluginPreferences()));
-// }
- manageIncludesDialog.restore();
- manageSymbolsDialog.restore();
- getContainer().updateContainer();
- }
-
- private void setSymbols(Preferences prefs) {
- prefs.setValue(PREF_SYMBOLS, stringArrayToString(getSymbolListContents()));
- }
-
- private void setIncludes(Preferences prefs) {
- prefs.setValue(PREF_INCLUDES, stringArrayToString(getPathListContents()));
- }
-
- private String stringArrayToString(String[] strings) {
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < strings.length; i++) {
- buf.append(strings[i]).append(';');
- }
- return buf.toString();
- }
-
- static String[] getSymbols(Preferences prefs) {
- String syms = prefs.getString(PREF_SYMBOLS);
- return parseStringToList(syms);
- }
-
- static String[] getIncludes(Preferences prefs) {
- String syms = prefs.getString(PREF_INCLUDES);
- return parseStringToList(syms);
- }
-
- private static String[] parseStringToList(String syms) {
- if (syms != null && syms.length() > 0) {
- StringTokenizer tok = new StringTokenizer(syms, ";"); //$NON-NLS-1$
- ArrayList list = new ArrayList(tok.countTokens());
- while (tok.hasMoreElements()) {
- list.add(tok.nextToken());
- }
- return (String[]) list.toArray(new String[list.size()]);
- }
- return new String[0];
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.wizards.IWizardTab#getControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- // Create the composite control for the tab
- int tabColumns = 3;
- Font font = parent.getFont();
- Composite composite = ControlFactory.createComposite(parent, tabColumns);
- ((GridLayout) composite.getLayout()).makeColumnsEqualWidth = false;
- composite.setFont(font);
- GridData gd;
- setControl(composite);
-
- WorkbenchHelp.setHelp(getControl(), IMakeHelpContextIds.MAKE_PATH_SYMBOL_SETTINGS);
-
- // Create a group for scanner config discovery
- createScannerConfigControls(composite, tabColumns);
-
- // Create a label for the include paths control
- Label paths = ControlFactory.createLabel(composite, MakeUIPlugin.getResourceString(PATHS));
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = tabColumns;
- gd.grabExcessHorizontalSpace = false;
- paths.setLayoutData(gd);
- paths.setFont(font);
-
- //Create the list and button controls
- createPathListControl(composite, tabColumns);
- createPathListButtons(composite);
-
- // Create a label for the symbols control
- Label symbols = ControlFactory.createLabel(composite, MakeUIPlugin.getResourceString(SYMBOLS));
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = tabColumns;
- gd.grabExcessHorizontalSpace = false;
- symbols.setLayoutData(gd);
- symbols.setFont(font);
-
- // Create list and button controls for symbols
- createSymbolListControl(composite, tabColumns);
- createSymbolListButtons(composite);
-
- setListContents();
- }
-
- /**
- * @param composite
- */
- private void createScannerConfigControls(Composite parent, int numColumns) {
- // Check if it is an old project
- IProject project = getContainer().getProject();
- boolean showMissingBuilder = false;
- try {
- if (project != null &&
- project.hasNature(MakeProjectNature.NATURE_ID) &&
- !project.hasNature(ScannerConfigNature.NATURE_ID)) {
- needsSCNature = true; // an old project
- }
- }
- catch (CoreException e) {
- showMissingBuilder = true;
- }
-
- // Create a ScannerConfigOptionsDialog
- if (scOptionsDialog == null) {
- if (needsSCNature) {
- // create a temporary dialog
- scOptionsDialog = new ScannerConfigOptionsDialog(getContainer());
- }
- else {
- scOptionsDialog = new ScannerConfigOptionsDialog(getShell(), getContainer());
- }
- }
-
- Group scGroup = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(SC_GROUP_LABEL), numColumns);
- scGroup.setFont(parent.getFont());
- ((GridData) scGroup.getLayoutData()).grabExcessHorizontalSpace = false;
- ((GridData) scGroup.getLayoutData()).horizontalSpan = numColumns;
- ((GridData) scGroup.getLayoutData()).horizontalAlignment = GridData.FILL;
- ((GridLayout) scGroup.getLayout()).marginWidth = 7;
-
- if ((!needsSCNature && !scOptionsDialog.isInitialized())) {
- ControlFactory.createLabel(scGroup, MakeUIPlugin.getResourceString(MISSING_BUILDER_MSG));
- return;
- }
-
- // Add checkbox
- scEnabledButton = ControlFactory.createCheckBox(scGroup, MakeUIPlugin.getResourceString(SC_ENABLED_LABEL));
- scEnabledButton.setFont(parent.getFont());
- ((GridData) scEnabledButton.getLayoutData()).horizontalSpan = 2;
- ((GridData) scEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
- // VMIR* old projects will have discovery disabled by default
- scEnabledButton.setSelection(needsSCNature ? false : scOptionsDialog.isScannerConfigDiscoveryEnabled());
- scEnabledButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleScannerConfigEnable();
- }
- });
- // Add Options... button
- scOptionsButton = ControlFactory.createPushButton(scGroup, MakeUIPlugin.getResourceString(SC_OPTIONS_LABEL));
- scOptionsButton.setFont(parent.getFont());
- ((GridData) scOptionsButton.getLayoutData()).grabExcessHorizontalSpace = false;
- SWTUtil.setButtonDimensionHint(scOptionsButton);
- scOptionsButton.setEnabled(scEnabledButton.getSelection());
- scOptionsButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- scOptionsDialog.open();
- }
- });
-// handleScannerConfigEnable(); Only if true in VMIR*
- }
-
- /**
- * Handles scanner configuration discovery selection change
- */
- protected void handleScannerConfigEnable() {
- boolean enable = scEnabledButton.getSelection();
- scOptionsButton.setEnabled(enable);
- if (enable && needsSCNature) {
- // first install the SC nature
- try {
- ScannerConfigNature.addScannerConfigNature(getContainer().getProject());
- // create the real dialog
- scOptionsDialog = new ScannerConfigOptionsDialog(getShell(), getContainer());
- needsSCNature = false;
- }
- catch (CoreException e) {
- MakeCorePlugin.log(e.getStatus());
- }
- }
- scOptionsDialog.setScannerConfigDiscoveryEnabled(enable);
- }
-
- private String[] getPathListContents() {
- return pathList.getItems();
- }
-
- private String[] getSymbolListContents() {
- return symbolList.getItems();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.wizards.IWizardTab#isValid()
- */
- public boolean isValid() {
- // Info on this page is not critical
- return true;
- }
-
- private void setListContents() {
- IProject project = getContainer().getProject();
- if (project != null) {
-// IScannerInfo info = CCorePlugin.getDefault().getScannerInfoProvider(project).getScannerInformation(project);
-// if (info != null) {
-// pathList.setItems(info.getIncludePaths());
-// symbolList.setItems(info.getPreprocessorSymbols());
-// }
- try {
- IDiscoveredPathInfo info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project);
- pathList.setItems(ScannerConfigUtil.iPathArray2StringArray(info.getIncludePaths()));
- LinkedHashMap discoveredSymbols = info.getSymbolMap();
- ArrayList activeSymbols = new ArrayList();
- activeSymbols.addAll(ScannerConfigUtil.scSymbolsSymbolEntryMap2List(discoveredSymbols, true));
- symbolList.setItems((String[]) activeSymbols.toArray(new String[activeSymbols.size()]));
- } catch (CoreException e) {
- MakeCorePlugin.log(e);
- }
- }
-// else {
-// pathList.setItems(getIncludes(MakeCorePlugin.getDefault().getPluginPreferences()));
-// symbolList.setItems(getSymbols(MakeCorePlugin.getDefault().getPluginPreferences()));
-// }
- }
-}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveredPathContainerPage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveredPathContainerPage.java
index 3701765770e..57e85f690a3 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveredPathContainerPage.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveredPathContainerPage.java
@@ -30,16 +30,19 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigUtil;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoCollector;
+import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.scannerconfig.DiscoveredElement;
import org.eclipse.cdt.make.internal.ui.scannerconfig.DiscoveredElementLabelProvider;
import org.eclipse.cdt.make.internal.ui.scannerconfig.DiscoveredElementSorter;
import org.eclipse.cdt.ui.wizards.IPathEntryContainerPage;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
@@ -128,7 +131,8 @@ public class DiscoveredPathContainerPage extends WizardPage implements IPathEntr
fDiscoveredContainerList.setDialogFieldListener(adapter);
fDiscoveredContainerList.setLabelText(MakeUIPlugin.getResourceString(CONTAINER_LIST_LABEL)); //$NON-NLS-1$
- fDiscoveredContainerList.setViewerSorter(new DiscoveredElementSorter());
+ fDiscoveredContainerList.setTreeExpansionLevel(2);
+ fDiscoveredContainerList.setViewerSorter(new DiscoveredElementSorter());
dirty = false;
}
@@ -563,18 +567,23 @@ public class DiscoveredPathContainerPage extends WizardPage implements IPathEntr
if (parent != null) {
Object[] children = parent.getChildren();
if (elem.delete()) {
+ // ScannerInfoCollector collector = ScannerInfoCollector.getInstance();
+ IProject project = fCProject.getProject();
+ SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
+ getSCProfileInstance(project, ScannerConfigProfileManager.NULL_PROFILE_ID); // use selected profile for the project
+ PerProjectSICollector collector = (PerProjectSICollector) profileInstance.getScannerInfoCollector();
switch (elem.getEntryKind()) {
case DiscoveredElement.PATHS_GROUP:
- ScannerInfoCollector.getInstance().deleteAllPaths(fCProject.getProject());
+ collector.deleteAllPaths(project);
break;
case DiscoveredElement.SYMBOLS_GROUP:
- ScannerInfoCollector.getInstance().deleteAllSymbols(fCProject.getProject());
+ collector.deleteAllSymbols(project);
break;
case DiscoveredElement.INCLUDE_PATH:
- ScannerInfoCollector.getInstance().deletePath(fCProject.getProject(), elem.getEntry());
+ collector.deletePath(project, elem.getEntry());
break;
case DiscoveredElement.SYMBOL_DEFINITION:
- ScannerInfoCollector.getInstance().deleteSymbol(fCProject.getProject(), elem.getEntry());
+ collector.deleteSymbol(project, elem.getEntry());
break;
}
rc = true;
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveryOptionsBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveryOptionsBlock.java
index 19f2c392e9c..642b5b3742c 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveryOptionsBlock.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveryOptionsBlock.java
@@ -1,50 +1,40 @@
-/**********************************************************************
+/***********************************************************************
* 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
+ * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
+ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
- **********************************************************************/
+ ***********************************************************************/
package org.eclipse.cdt.make.ui.dialogs;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ICDescriptor;
+import org.eclipse.cdt.core.ICDescriptorOperation;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.MakeProjectNature;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigBuilder;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
-import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -54,567 +44,311 @@ 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.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.help.WorkbenchHelp;
/**
- * A dialog to set scanner config discovery options
+ * A dialog to set scanner config discovery options.
*
* @author vhirsl
+ * @since 3.0
*/
-public class DiscoveryOptionsBlock extends AbstractCOptionPage {
-
- private static final String PREFIX_BP = "BuildPathInfoBlock"; //$NON-NLS-1$
- private static final String SC_GROUP_LABEL = PREFIX_BP + ".scGroup.label"; //$NON-NLS-1$
- private static final String SC_ENABLED_LABEL = PREFIX_BP + ".scGroup.enabled.label"; //$NON-NLS-1$
- private static final String MISSING_BUILDER_MSG = "ScannerConfigOptionsDialog.label.missingBuilderInformation"; //$NON-NLS-1$
-
- private static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
- private static final String DIALOG_TITLE = PREFIX + ".title"; //$NON-NLS-1$
- private static final String DIALOG_DESCRIPTION = PREFIX + ".description"; //$NON-NLS-1$
- private static final String SI_BUILD_PARSER_GROUP = PREFIX + ".siBuilder.parser.group_label"; //$NON-NLS-1$
- private static final String ENABLE_SI_BUILD_PARSER = PREFIX + ".siBuilder.parser.enable.label"; //$NON-NLS-1$
- private static final String SI_BUILD_PARSER_LABEL = PREFIX + ".siBuilder.parser.label"; //$NON-NLS-1$
- private static final String SI_PROVIDER_CMD_GROUP = PREFIX + ".siProvider.cmd.group_label"; //$NON-NLS-1$
- private static final String ENABLE_SI_PROVIDER_COMMAND = PREFIX + ".siProvider.cmd.enable.label"; //$NON-NLS-1$
- private static final String SI_PROVIDER_CMD_USE_DEFAULT = PREFIX + ".siProvider.cmd.use_default"; //$NON-NLS-1$
- private static final String SI_PROVIDER_CMD_LABEL = PREFIX + ".siProvider.cmd.label"; //$NON-NLS-1$
- private static final String SI_PROVIDER_PARSER_LABEL = PREFIX + ".siProvider.parser.label"; //$NON-NLS-1$
- private static final String SI_PROVIDER_CMD_ERROR_MESSAGE = PREFIX + ".siProvider.cmd.error_message"; //$NON-NLS-1$
- private static final String SI_PROBLEM_GROUP = PREFIX + ".siProblem.group.label"; //$NON-NLS-1$
- private static final String ENABLE_SI_PROBLEM_GENERATION = PREFIX + ".siProblem.generation.enable.label"; //$NON-NLS-1$
-
- private Button scEnabledButton;
- private boolean needsSCNature = false;
-
- private Button defESIProviderCommandButton;
- private Text esiProviderCommand;
- private Button enableBuilderParserButton;
- private Combo makeBuilderSIParserComboBox;
- private Button enableProviderCommandButton;
- private Combo esiProviderParserComboBox;
- private Button enableProblemGenerationButton;
-
- private Preferences fPrefs;
- private IScannerConfigBuilderInfo fBuildInfo;
- private boolean fInitialized = false;
- private Map builderParsers = new HashMap();
- private String initialBuilderParserId = null;
- private Map providerParsers = new HashMap();
- private String initialProviderParserId = null;
- private boolean fCreatePathContainer = false;
-
- public DiscoveryOptionsBlock() {
- super(MakeUIPlugin.getResourceString(DIALOG_TITLE));
- setDescription(MakeUIPlugin.getResourceString(DIALOG_DESCRIPTION));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#setContainer(org.eclipse.cdt.ui.dialogs.ICOptionContainer)
- */
- public void setContainer(ICOptionContainer container) {
- super.setContainer(container);
-
- fPrefs = getContainer().getPreferences();
- IProject project = getContainer().getProject();
-
- fInitialized = true;
- if (project != null) {
- try {
- fBuildInfo = MakeCorePlugin.createScannerConfigBuildInfo(project, ScannerConfigBuilder.BUILDER_ID);
- } catch (CoreException e) {
- // missing builder information (builder disabled or legacy project)
- fInitialized = false;
- fBuildInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, true);
- }
- } else {
- fCreatePathContainer = true;
- fBuildInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, false);
- }
- retrieveSIConsoleParsers();
- initialBuilderParserId = fBuildInfo.getMakeBuilderConsoleParserId(); //$NON-NLS-1$
- initialProviderParserId = fBuildInfo.getESIProviderConsoleParserId(); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void performApply(IProgressMonitor monitor) throws CoreException {
- if (!fInitialized && !needsSCNature) {
- // Missing builder info on a non-legacy project
- return;
- }
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- IWorkspace workspace = MakeUIPlugin.getWorkspace();
-
- // To avoid multi-build
- IWorkspaceRunnable operation = new IWorkspaceRunnable() {
-
- public void run(IProgressMonitor monitor) throws CoreException {
- IScannerConfigBuilderInfo buildInfo;
- IProject project = getContainer().getProject();
- if (project != null) {
- if (needsSCNature) {
- ScannerConfigNature.addScannerConfigNature(getContainer().getProject());
- needsSCNature = false;
- fCreatePathContainer = true;
- }
- try {
- buildInfo = MakeCorePlugin.createScannerConfigBuildInfo(project, ScannerConfigBuilder.BUILDER_ID);
- } catch (CoreException e) {
- // disabled builder... just log it
- MakeCorePlugin.log(e);
- return;
- }
- if (fCreatePathContainer) {
- createDiscoveredPathContainer(project, monitor);
- // create a new discovered scanner config store
- MakeCorePlugin.getDefault().getDiscoveryManager().removeDiscoveredInfo(project);
- fCreatePathContainer = false;
- }
- } else {
- buildInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, false);
- }
-
- buildInfo.setAutoDiscoveryEnabled(isScannerConfigDiscoveryEnabled());
- if (isScannerConfigDiscoveryEnabled()) {
- buildInfo.setMakeBuilderConsoleParserEnabled(isBuilderParserEnabled());
- if (isBuilderParserEnabled()) {
- buildInfo.setMakeBuilderConsoleParserId((String)builderParsers.get(makeBuilderSIParserComboBox.getText()));
- }
- buildInfo.setESIProviderCommandEnabled(isProviderCommandEnabled());
- if (isProviderCommandEnabled()) {
- buildInfo.setUseDefaultESIProviderCmd(useDefaultESIProviderCmd());
- if (!useDefaultESIProviderCmd()) {
- storeSIProviderCommandLine(buildInfo);
- }
- buildInfo.setESIProviderConsoleParserId((String)providerParsers.get(esiProviderParserComboBox.getText()));
- }
- buildInfo.setSIProblemGenerationEnabled(isProblemGenerationEnabled());
- }
- }
- };
- if (getContainer().getProject() != null) {
- workspace.run(operation, monitor);
- } else {
- operation.run(monitor);
- }
- }
- /**
- * @param project
- * @param monitor
- * @throws CModelException
- */
- private void createDiscoveredPathContainer(IProject project, IProgressMonitor monitor) throws CModelException {
- IPathEntry container = CoreModel.newContainerEntry(DiscoveredPathContainer.CONTAINER_ID);
- ICProject cProject = CoreModel.getDefault().create(project);
- if (cProject != null) {
- IPathEntry[] entries = cProject.getRawPathEntries();
- List newEntries = new ArrayList(Arrays.asList(entries));
- if (!newEntries.contains(container)) {
- newEntries.add(container);
- cProject.setRawPathEntries((IPathEntry[])newEntries.toArray(new IPathEntry[newEntries.size()]), monitor);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
- */
- public void performDefaults() {
- if (!fInitialized && !needsSCNature) {
- // Missing builder info on a non-legacy project
- return;
- }
- IScannerConfigBuilderInfo info;
- // Populate with the default values
- if (getContainer().getProject() != null) {
- // get the preferences
- info = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, false);
- } else {
- // get the defaults
- info = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, true);
- }
-
- setScannerConfigDiscoveryEnabled(info.isAutoDiscoveryEnabled());
- enableBuilderParserButton.setSelection(info.isMakeBuilderConsoleParserEnabled());
- makeBuilderSIParserComboBox.setText(getParserName(builderParsers, info.getMakeBuilderConsoleParserId()));
- enableProviderCommandButton.setSelection(info.isESIProviderCommandEnabled());
- defESIProviderCommandButton.setSelection(info.isDefaultESIProviderCmd());
- setESIProviderCommandFrom(info);
- esiProviderParserComboBox.setText(getParserName(providerParsers, info.getESIProviderConsoleParserId()));
-
- enableAllControls();
- }
-
- /**
- * @param parsers
- * @param consoleParserId
- * @return
- */
- private String getParserName(Map parsers, String consoleParserId) {
- for (Iterator i = parsers.keySet().iterator(); i.hasNext();) {
- String parserName = (String)i.next();
- String parserId = (String)parsers.get(parserName);
- if (parserId.equals(consoleParserId)) {
- return parserName;
- }
- }
- return consoleParserId;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- // Create the composite control for the tab
- int tabColumns = 1;
- Font font = parent.getFont();
- Composite composite = ControlFactory.createComposite(parent, tabColumns);
- ((GridLayout)composite.getLayout()).makeColumnsEqualWidth = false;
- composite.setFont(font);
- setControl(composite);
-
- WorkbenchHelp.setHelp(getControl(), IMakeHelpContextIds.SCANNER_CONFIG_DISCOVERY_OPTIONS);
-
- // Create a group for scanner config discovery
- if (createScannerConfigControls(composite, tabColumns)) {
- createBuildOutputParserControls(composite);
- createAfterBuildCmdControls(composite);
- createProblemGenerationControls(composite);
- // enable controls depending on the state of auto discovery
- enableAllControls();
- }
- }
-
- /**
- * @param composite
- */
- private boolean createScannerConfigControls(Composite parent, int numColumns) {
- // Check if it is an old project
- IProject project = getContainer().getProject();
- boolean showMissingBuilder = false;
- try {
- if (project != null && project.hasNature(MakeProjectNature.NATURE_ID)
- && !project.hasNature(ScannerConfigNature.NATURE_ID)) {
- needsSCNature = true; // legacy project
- }
- } catch (CoreException e) {
- showMissingBuilder = true;
- }
-
- if (showMissingBuilder || (!needsSCNature && !fInitialized)) {
- ControlFactory.createEmptySpace(parent);
- ControlFactory.createLabel(parent, MakeUIPlugin.getResourceString(MISSING_BUILDER_MSG));
- return false;
- }
-
- Group scGroup = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(SC_GROUP_LABEL), numColumns);
- scGroup.setFont(parent.getFont());
- ((GridData)scGroup.getLayoutData()).grabExcessHorizontalSpace = true;
- ((GridData)scGroup.getLayoutData()).horizontalSpan = numColumns;
- ((GridData)scGroup.getLayoutData()).horizontalAlignment = GridData.FILL;
-
- // Add checkbox
- scEnabledButton = ControlFactory.createCheckBox(scGroup, MakeUIPlugin.getResourceString(SC_ENABLED_LABEL));
- scEnabledButton.setFont(parent.getFont());
- ((GridData)scEnabledButton.getLayoutData()).horizontalSpan = numColumns;
- ((GridData)scEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
- // VMIR* old projects will have discovery disabled by default
- scEnabledButton.setSelection(needsSCNature ? false : fBuildInfo.isAutoDiscoveryEnabled());
- scEnabledButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- enableAllControls();
- }
- });
- // handleScannerConfigEnable(); Only if true in VMIR*
- return true;
- }
-
- /**
- * Fills console parser maps
- */
- private void retrieveSIConsoleParsers() {
- IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(MakeCorePlugin.getUniqueIdentifier(),
- MakeCorePlugin.SI_CONSOLE_PARSER_SIMPLE_ID);
- if (ep != null) {
- IExtension[] extensions = ep.getExtensions();
- for (int i = 0; i < extensions.length; ++i) {
- String parserId = extensions[i].getUniqueIdentifier();
- String label = extensions[i].getLabel();
- IConfigurationElement[] elements = extensions[i].getConfigurationElements();
- String commandId = elements[0].getAttribute("commandId"); //$NON-NLS-1$
- if (commandId.equals("makeBuilder") || commandId.equals("all")) { //$NON-NLS-1$//$NON-NLS-2$
- builderParsers.put(label, parserId);
- }
- if (commandId.equals("externalScannerInfoProvider") || commandId.equals("all")) { //$NON-NLS-1$//$NON-NLS-2$
- providerParsers.put(label, parserId);
- }
- }
- }
- }
-
- private void createBuildOutputParserControls(Composite parent) {
- // ControlFactory.insertSpace(parent, 1, 10);
- Group bopGroup = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(SI_BUILD_PARSER_GROUP), 2);
- ((GridLayout)bopGroup.getLayout()).marginHeight = 5;
- ((GridLayout)bopGroup.getLayout()).marginWidth = 5;
- ((GridData)bopGroup.getLayoutData()).verticalAlignment = GridData.FILL;
- ((GridData)bopGroup.getLayoutData()).horizontalSpan = 2;
-
- enableBuilderParserButton = ControlFactory.createCheckBox(bopGroup, MakeUIPlugin.getResourceString(ENABLE_SI_BUILD_PARSER));
- ((GridData)enableBuilderParserButton.getLayoutData()).horizontalSpan = 2;
- boolean enabledBuilderParser = fBuildInfo.isMakeBuilderConsoleParserEnabled();
- enableBuilderParserButton.setSelection(enabledBuilderParser);
- enableBuilderParserButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- makeBuilderSIParserComboBox.setEnabled(isBuilderParserEnabled());
- }
- });
-
- Label label = ControlFactory.createLabel(bopGroup, MakeUIPlugin.getResourceString(SI_BUILD_PARSER_LABEL));
- ((GridData)label.getLayoutData()).grabExcessHorizontalSpace = false;
-
- makeBuilderSIParserComboBox = new Combo(bopGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
-
- // fill the combobox and set the initial value
- for (Iterator items = builderParsers.keySet().iterator(); items.hasNext();) {
- String parser = (String)items.next();
- makeBuilderSIParserComboBox.add(parser);
- if (initialBuilderParserId.equals(builderParsers.get(parser))) {
- makeBuilderSIParserComboBox.setText(parser);
- }
- }
- makeBuilderSIParserComboBox.setEnabled(enabledBuilderParser);
- }
-
- private void createAfterBuildCmdControls(Composite parent) {
- Group abcGroup = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(SI_PROVIDER_CMD_GROUP), 2);
- ((GridData)abcGroup.getLayoutData()).horizontalSpan = 2;
-
- enableProviderCommandButton = ControlFactory.createCheckBox(abcGroup,
- MakeUIPlugin.getResourceString(ENABLE_SI_PROVIDER_COMMAND));
- ((GridData)enableProviderCommandButton.getLayoutData()).horizontalSpan = 2;
- ((GridData)enableProviderCommandButton.getLayoutData()).horizontalAlignment = GridData.FILL_HORIZONTAL;
- boolean enabledProviderCommand = fBuildInfo.isESIProviderCommandEnabled();
- enableProviderCommandButton.setSelection(enabledProviderCommand);
- enableProviderCommandButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- defESIProviderCommandButton.setEnabled(isProviderCommandEnabled());
- esiProviderCommand.setEnabled(isProviderCommandEnabled() && !useDefaultESIProviderCmd());
- esiProviderParserComboBox.setEnabled(isProviderCommandEnabled());
- getContainer().updateContainer();
- }
- });
-
- createESIProviderCmdControls(abcGroup);
-
- Label label = ControlFactory.createLabel(abcGroup, MakeUIPlugin.getResourceString(SI_PROVIDER_PARSER_LABEL));
- ((GridData)label.getLayoutData()).grabExcessHorizontalSpace = false;
-
- esiProviderParserComboBox = new Combo(abcGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
-
- // fill the combobox and set the initial value
- for (Iterator items = providerParsers.keySet().iterator(); items.hasNext();) {
- String parser = (String)items.next();
- esiProviderParserComboBox.add(parser);
- if (initialProviderParserId.equals(providerParsers.get(parser))) {
- esiProviderParserComboBox.setText(parser);
- }
- }
- defESIProviderCommandButton.setEnabled(enabledProviderCommand);
- esiProviderCommand.setEnabled(enabledProviderCommand && !useDefaultESIProviderCmd());
- esiProviderParserComboBox.setEnabled(enabledProviderCommand);
- }
-
- private void createESIProviderCmdControls(Composite parent) {
- defESIProviderCommandButton = ControlFactory.createCheckBox(parent,
- MakeUIPlugin.getResourceString(SI_PROVIDER_CMD_USE_DEFAULT));
- defESIProviderCommandButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- esiProviderCommand.setEnabled(!useDefaultESIProviderCmd());
- getContainer().updateContainer();
- }
- });
- ((GridData) (defESIProviderCommandButton.getLayoutData())).horizontalAlignment = GridData.FILL_HORIZONTAL;
- ((GridData) (defESIProviderCommandButton.getLayoutData())).horizontalSpan = 2;
- Label label = ControlFactory.createLabel(parent, MakeUIPlugin.getResourceString(SI_PROVIDER_CMD_LABEL));
- ((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING;
- ((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false;
- esiProviderCommand = ControlFactory.createTextField(parent, SWT.SINGLE | SWT.BORDER);
- ((GridData) (esiProviderCommand.getLayoutData())).horizontalAlignment = GridData.FILL;
- ((GridData) (esiProviderCommand.getLayoutData())).grabExcessHorizontalSpace = true;
- setESIProviderCommandFrom(fBuildInfo);
- if (fBuildInfo.isDefaultESIProviderCmd()) {
- esiProviderCommand.setEnabled(false);
- }
- esiProviderCommand.addListener(SWT.Modify, new Listener() {
-
- public void handleEvent(Event e) {
- getContainer().updateContainer();
- }
- });
- defESIProviderCommandButton.setSelection(fBuildInfo.isDefaultESIProviderCmd());
- }
-
- /**
- * @param composite
- */
- private void createProblemGenerationControls(Composite parent) {
- Group problemGroup = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(SI_PROBLEM_GROUP), 2);
- ((GridData)problemGroup.getLayoutData()).horizontalSpan = 2;
-
- enableProblemGenerationButton = ControlFactory.createCheckBox(problemGroup,
- MakeUIPlugin.getResourceString(ENABLE_SI_PROBLEM_GENERATION));
- ((GridData)enableProblemGenerationButton.getLayoutData()).horizontalSpan = 2;
- ((GridData)enableProblemGenerationButton.getLayoutData()).horizontalAlignment = GridData.FILL_HORIZONTAL;
- boolean enabledProblemGeneration = fBuildInfo.isSIProblemGenerationEnabled();
- enableProblemGenerationButton.setSelection(enabledProblemGeneration);
- enableProblemGenerationButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- getContainer().updateContainer();
- }
- });
-
- }
-
- /**
- * @param buildInfo
- */
- private void setESIProviderCommandFrom(IScannerConfigBuilderInfo buildInfo) {
- IPath sCommand = buildInfo.getESIProviderCommand();
- if (sCommand != null) {
- StringBuffer cmd = new StringBuffer(sCommand.toOSString());
- String args = buildInfo.getESIProviderArguments();
- if (args != null && args.length() > 0) {
- cmd.append(' ');
- cmd.append(args);
- }
- esiProviderCommand.setText(cmd.toString());
- }
- }
-
- /**
- * @param enable
- */
- private void enableAllControls() {
- enableBuilderParserButton.setEnabled(isScannerConfigDiscoveryEnabled());
- makeBuilderSIParserComboBox.setEnabled(isScannerConfigDiscoveryEnabled() && isBuilderParserEnabled());
- enableProviderCommandButton.setEnabled(isScannerConfigDiscoveryEnabled());
- defESIProviderCommandButton.setEnabled(isScannerConfigDiscoveryEnabled() && isProviderCommandEnabled());
- esiProviderCommand.setEnabled(isScannerConfigDiscoveryEnabled() && isProviderCommandEnabled()
- && !useDefaultESIProviderCmd());
- esiProviderParserComboBox.setEnabled(isScannerConfigDiscoveryEnabled() && isProviderCommandEnabled());
- enableProblemGenerationButton.setEnabled(isScannerConfigDiscoveryEnabled());
- }
-
- private boolean useDefaultESIProviderCmd() {
- return defESIProviderCommandButton.getSelection();
- }
-
- private String getSIProviderCommandLine() {
- return esiProviderCommand.getText().trim();
- }
-
- private boolean isBuilderParserEnabled() {
- return enableBuilderParserButton.getSelection();
- }
-
- private boolean isProviderCommandEnabled() {
- return enableProviderCommandButton.getSelection();
- }
-
- private boolean isProblemGenerationEnabled() {
- return enableProblemGenerationButton.getSelection();
- }
-
- /**
- * Retrieves the state of scanner config discovery
- *
- * @return boolean
- */
- private boolean isScannerConfigDiscoveryEnabled() {
- return scEnabledButton.getSelection();
- }
-
- /**
- * Enables or disables the scanner config discovery
- *
- * @param enabled
- * (boolean)
- */
- private void setScannerConfigDiscoveryEnabled(boolean enabled) {
- scEnabledButton.setSelection(enabled);
- }
-
- /**
- * @param buildInfo
- * @throws CoreException
- */
- private void storeSIProviderCommandLine(IScannerConfigBuilderInfo buildInfo) throws CoreException {
- String esiProviderLine = getSIProviderCommandLine();
- int start = 0;
- int end = -1;
- if (esiProviderLine.startsWith("\"")) { //$NON-NLS-1$
- start = 1;
- end = esiProviderLine.indexOf('"', 1);
- } else {
- end = esiProviderLine.indexOf(' ');
- }
- IPath path;
- if (end == -1) {
- path = new Path(esiProviderLine);
- } else {
- path = new Path(esiProviderLine.substring(start, end));
- }
- buildInfo.setESIProviderCommand(path);
- String args = ""; //$NON-NLS-1$
- if (end != -1) {
- args = esiProviderLine.substring(end + 1);
- }
- buildInfo.setESIProviderArguments(args);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#isValid()
- */
- public boolean isValid() {
- if (fInitialized && isProviderCommandEnabled() && !useDefaultESIProviderCmd()) {
- String cmd = getSIProviderCommandLine();
- if (cmd == null || cmd.length() == 0) {
- return false;
- }
- }
- return true;
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.IDialogPage#getErrorMessage()
- */
- public String getErrorMessage() {
- if (!isValid()) {
- return MakeUIPlugin.getResourceString(SI_PROVIDER_CMD_ERROR_MESSAGE);
- }
- return null;
- }
-} \ No newline at end of file
+public class DiscoveryOptionsBlock extends AbstractDiscoveryOptionsBlock {
+ private static final String MISSING_BUILDER_MSG = "ScannerConfigOptionsDialog.label.missingBuilderInformation"; //$NON-NLS-1$
+
+ private static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
+ private static final String DIALOG_TITLE = PREFIX + ".title"; //$NON-NLS-1$
+ private static final String DIALOG_DESCRIPTION = PREFIX + ".description"; //$NON-NLS-1$
+ private static final String SC_GROUP_LABEL = PREFIX + ".scGroup.label"; //$NON-NLS-1$
+ private static final String SC_ENABLED_BUTTON = PREFIX + ".scGroup.enabled.button"; //$NON-NLS-1$
+ private static final String SC_PROBLEM_REPORTING_ENABLED_BUTTON = PREFIX + ".scGroup.problemReporting.enabled.button"; //$NON-NLS-1$
+ private static final String SC_SELECTED_PROFILE_COMBO = PREFIX + ".scGroup.selectedProfile.combo"; //$NON-NLS-1$
+ private static final String BO_PROVIDER_GROUP_LABEL = PREFIX + ".boProvider.group.label"; //$NON-NLS-1$
+ private static final String SC_APPLY_PROGRESS_MESSAGE = PREFIX + ".apply.progressMessage"; //$NON-NLS-1$
+
+ private Button scEnabledButton;
+ private Button scProblemReportingEnabledButton;
+ private Combo profileComboBox;
+ private Composite profileComp;
+
+ private boolean needsSCNature = false;
+ private boolean fCreatePathContainer = false;
+ private boolean isValid = true;
+
+ /**
+ *
+ */
+ public DiscoveryOptionsBlock() {
+ super(MakeUIPlugin.getResourceString(DIALOG_TITLE));
+ setDescription(MakeUIPlugin.getResourceString(DIALOG_DESCRIPTION));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#setContainer(org.eclipse.cdt.ui.dialogs.ICOptionContainer)
+ */
+ public void setContainer(ICOptionContainer container) {
+ super.setContainer(container);
+ if (container.getProject() == null) {
+ fCreatePathContainer = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ // Create the composite control for the tab
+ int tabColumns = 2;
+ Font font = parent.getFont();
+ Composite composite = ControlFactory.createComposite(parent, 1);
+ ((GridLayout)composite.getLayout()).marginHeight = 0;
+ ((GridLayout)composite.getLayout()).marginWidth = 0;
+ ((GridLayout)composite.getLayout()).verticalSpacing = 0;
+ ((GridData)composite.getLayoutData()).horizontalAlignment = GridData.FILL_HORIZONTAL;
+ composite.setFont(font);
+ setControl(composite);
+
+ WorkbenchHelp.setHelp(getControl(), IMakeHelpContextIds.SCANNER_CONFIG_DISCOVERY_OPTIONS);
+
+ // create a composite for general scanner config discovery options
+ Composite scComp = ControlFactory.createComposite(composite, 1);
+ ((GridLayout)scComp.getLayout()).marginHeight = 0;
+ ((GridLayout)scComp.getLayout()).marginTop = 5;
+ scComp.setFont(font);
+
+ // Create a group for scanner config discovery
+ if (createScannerConfigControls(scComp, tabColumns)) {
+ // create a composite for discovery profile options
+ profileComp = ControlFactory.createComposite(composite, 1);
+ // ((GridLayout)profileComp.getLayout()).marginHeight = 5;
+ // ((GridLayout)profileComp.getLayout()).marginWidth = 5;
+ // ((GridLayout)profileComp.getLayout()).verticalSpacing = 5;
+ profileComp.setFont(font);
+ GridData gd = (GridData) profileComp.getLayoutData();
+ gd.grabExcessHorizontalSpace = true;
+ // gd.grabExcessVerticalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.FILL;
+
+ // Must set the composite parent to super class.
+ setCompositeParent(profileComp);
+ // fire a change event, to quick start.
+ handleDiscoveryProfileChanged();
+ // enable controls depending on the state of auto discovery
+ enableAllControls();
+ }
+ parent.layout(true);
+ }
+
+ private boolean createScannerConfigControls(Composite parent, int numColumns) {
+ // Check if it is an old project
+ IProject project = getContainer().getProject();
+ boolean showMissingBuilder = false;
+ try {
+ if (project != null && project.hasNature(MakeProjectNature.NATURE_ID)
+ && !project.hasNature(ScannerConfigNature.NATURE_ID)) {
+ needsSCNature = true; // legacy project
+ }
+ } catch (CoreException e) {
+ showMissingBuilder = true;
+ }
+
+ if (showMissingBuilder || (!needsSCNature && !isInitialized())) {
+ ControlFactory.createEmptySpace(parent);
+ ControlFactory.createLabel(parent, MakeUIPlugin.getResourceString(MISSING_BUILDER_MSG));
+ return false;
+ }
+
+ Group scGroup = ControlFactory.createGroup(parent,
+ MakeUIPlugin.getResourceString(SC_GROUP_LABEL), numColumns);
+ scGroup.setFont(parent.getFont());
+ ((GridData)scGroup.getLayoutData()).grabExcessHorizontalSpace = true;
+ ((GridData)scGroup.getLayoutData()).horizontalSpan = numColumns;
+ ((GridData)scGroup.getLayoutData()).horizontalAlignment = GridData.FILL;
+
+ // Add main SCD checkbox
+ scEnabledButton = ControlFactory.createCheckBox(scGroup,
+ MakeUIPlugin.getResourceString(SC_ENABLED_BUTTON));
+ scEnabledButton.setFont(parent.getFont());
+ ((GridData)scEnabledButton.getLayoutData()).horizontalSpan = numColumns;
+ ((GridData)scEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
+ // VMIR* old projects will have discovery disabled by default
+ scEnabledButton.setSelection(needsSCNature ? false : getBuildInfo().isAutoDiscoveryEnabled());
+ scEnabledButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ enableAllControls();
+ }
+ });
+ // handleScannerConfigEnable(); Only if true in VMIR*
+
+ // Add problem reporting checkbox
+ scProblemReportingEnabledButton = ControlFactory.createCheckBox(scGroup,
+ MakeUIPlugin.getResourceString(SC_PROBLEM_REPORTING_ENABLED_BUTTON));
+ scProblemReportingEnabledButton.setFont(parent.getFont());
+ ((GridData)scProblemReportingEnabledButton.getLayoutData()).horizontalSpan = numColumns;
+ ((GridData)scProblemReportingEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
+ scProblemReportingEnabledButton.setSelection(getBuildInfo().isProblemReportingEnabled());
+
+ // Add profile combo box
+ Label label = ControlFactory.createLabel(scGroup,
+ MakeUIPlugin.getResourceString(SC_SELECTED_PROFILE_COMBO));
+ ((GridData)label.getLayoutData()).grabExcessHorizontalSpace = false;
+
+ profileComboBox = new Combo(scGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
+
+ // fill the combobox and set the initial value
+ for (Iterator items = getDiscoveryProfileIdList().iterator(); items.hasNext();) {
+ String profileId = (String)items.next();
+ String pageName = getDiscoveryProfileName(profileId);
+ if (pageName != null) {
+ profileComboBox.add(pageName);
+ if (profileId.equals(getBuildInfo().getSelectedProfileId())) {
+ profileComboBox.setText(pageName);
+ }
+ }
+ }
+ profileComboBox.setEnabled(scEnabledButton.getSelection());
+
+ return true;
+ }
+
+ /**
+ *
+ */
+ private void enableAllControls() {
+ boolean isSCDEnabled = scEnabledButton.getSelection();
+ scProblemReportingEnabledButton.setEnabled(isSCDEnabled);
+ profileComboBox.setEnabled(isSCDEnabled);
+ profileComp.setVisible(isSCDEnabled);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ enableAllControls();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryOptionsBlock#getCurrentProfileId()
+ */
+ protected String getCurrentProfileId() {
+ String selectedProfileName = profileComboBox.getItem(profileComboBox.getSelectionIndex());
+ String selectedProfileId = getDiscoveryProfileId(selectedProfileName);
+ return selectedProfileId;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void performApply(IProgressMonitor monitor) throws CoreException {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask(MakeUIPlugin.getResourceString(SC_APPLY_PROGRESS_MESSAGE), 3);
+
+ // init buildInfo
+ final IProject project = getContainer().getProject();
+ // Create new build info in case of new C++ project wizard
+ final IScannerConfigBuilderInfo2 buildInfo = createBuildInfo(project);
+
+ if (buildInfo != null) {
+ populateBuildInfo(buildInfo);
+ buildInfo.store();
+ monitor.worked(1);
+
+ if (scEnabledButton.getSelection()) {
+ getCurrentPage().performApply(monitor);
+ }
+ monitor.worked(1);
+
+ if (project != null) {
+ configureProject(project, monitor);
+ ICDescriptorOperation op = new ICDescriptorOperation() {
+
+ public void execute(ICDescriptor descriptor, IProgressMonitor monitor) throws CoreException {
+ buildInfo.save();
+ }
+
+ };
+ CCorePlugin.getDefault().getCDescriptorManager().
+ runDescriptorOperation(project, op, monitor);
+ }
+ else {
+ buildInfo.save();
+ }
+ }
+ monitor.done();
+ }
+
+ private void configureProject(IProject project, IProgressMonitor monitor) throws CoreException {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask(MakeUIPlugin.getResourceString(SC_APPLY_PROGRESS_MESSAGE), 3);
+
+ if (needsSCNature) {
+ ScannerConfigNature.addScannerConfigNature(project);
+ needsSCNature = false;
+ fCreatePathContainer = true;
+ }
+ if (fCreatePathContainer) {
+ createDiscoveredPathContainer(project, monitor);
+ fCreatePathContainer = false;
+ }
+ }
+
+ /**
+ * @param project
+ * @param monitor
+ * @throws CModelException
+ */
+ private void createDiscoveredPathContainer(IProject project, IProgressMonitor monitor) throws CModelException {
+ IPathEntry container = CoreModel.newContainerEntry(DiscoveredPathContainer.CONTAINER_ID);
+ ICProject cProject = CoreModel.getDefault().create(project);
+ if (cProject != null) {
+ IPathEntry[] entries = cProject.getRawPathEntries();
+ List newEntries = new ArrayList(Arrays.asList(entries));
+ if (!newEntries.contains(container)) {
+ newEntries.add(container);
+ cProject.setRawPathEntries((IPathEntry[])newEntries.toArray(new IPathEntry[newEntries.size()]), monitor);
+ }
+ }
+ // create a new discovered scanner config store
+ MakeCorePlugin.getDefault().getDiscoveryManager().removeDiscoveredInfo(project);
+ }
+
+ private void populateBuildInfo(IScannerConfigBuilderInfo2 buildInfo) {
+ buildInfo.setAutoDiscoveryEnabled(scEnabledButton.getSelection());
+ String profileName = profileComboBox.getItem(profileComboBox.getSelectionIndex());
+ buildInfo.setSelectedProfileId(getDiscoveryProfileId(profileName));
+ buildInfo.setProblemReportingEnabled(scProblemReportingEnabledButton.getSelection());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
+ */
+
+ public void performDefaults() {
+ if (!isInitialized() && !needsSCNature) {
+ // Missing builder info on a non-legacy project
+ return;
+ }
+ IScannerConfigBuilderInfo2 buildInfo = createBuildInfo();
+
+ restoreFromBuildinfo(buildInfo);
+ enableAllControls();
+
+ getCurrentPage().performDefaults();
+ }
+
+ private void restoreFromBuildinfo(IScannerConfigBuilderInfo2 buildInfo) {
+ scEnabledButton.setSelection(buildInfo.isAutoDiscoveryEnabled());
+ String profileId = buildInfo.getSelectedProfileId();
+ profileComboBox.setText(getDiscoveryProfileName(profileId));
+ scProblemReportingEnabledButton.setSelection(buildInfo.isProblemReportingEnabled());
+ }
+
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerProjectSCDProfilePage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerProjectSCDProfilePage.java
new file mode 100644
index 00000000000..f95ad96c5d7
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerProjectSCDProfilePage.java
@@ -0,0 +1,364 @@
+/***********************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ ***********************************************************************/
+package org.eclipse.cdt.make.ui.dialogs;
+
+import java.io.File;
+
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.internal.core.scannerconfig.jobs.BuildOutputReaderJob;
+import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.swt.SWT;
+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.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * SCD profile property/preference page
+ *
+ * @author vhirsl
+ */
+public class GCCPerProjectSCDProfilePage extends AbstractDiscoveryPage {
+ private static final int DEFAULT_HEIGHT = 160;
+
+ private static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
+ private static final String BO_PROVIDER_GROUP_LABEL = PREFIX + ".boProvider.group.label"; //$NON-NLS-1$
+ private static final String BO_PROVIDER_PARSER_ENABLED_BUTTON = PREFIX + ".boProvider.parser.enabled.button"; //$NON-NLS-1$
+ private static final String BO_PROVIDER_OPEN_LABEL = PREFIX + ".boProvider.open.label"; //$NON-NLS-1$
+ private static final String BO_PROVIDER_BROWSE_BUTTON = PREFIX + ".boProvider.browse.button"; //$NON-NLS-1$
+ private static final String BO_PROVIDER_OPEN_FILE_DIALOG = PREFIX + ".boProvider.browse.openFileDialog"; //$NON-NLS-1$
+ private static final String BO_PROVIDER_LOAD_BUTTON = PREFIX + ".boProvider.load.button"; //$NON-NLS-1$
+ private static final String SI_PROVIDER_PARSER_ENABLED_BUTTON = PREFIX + ".siProvider.parser.enabled.button"; //$NON-NLS-1$
+ private static final String SI_PROVIDER_COMMAND_LABEL = PREFIX + ".siProvider.command.label"; //$NON-NLS-1$
+ private static final String SI_PROVIDER_BROWSE_BUTTON = PREFIX + ".siProvider.browse.button"; //$NON-NLS-1$
+ private static final String SI_PROVIDER_COMMAND_DIALOG = PREFIX + ".siProvider.browse.runCommandDialog"; //$NON-NLS-1$
+ private static final String SI_PROVIDER_COMMAND_ERROR_MESSAGE= PREFIX + ".siProvider.command.errorMessage"; //$NON-NLS-1$
+
+ private static final String providerId = "specsFile"; //$NON-NLS-1$
+
+ // thread syncronization
+ //private static ILock lock = Platform.getJobManager().newLock();
+// private static Object lock = new Object();
+ private static Object lock = GCCPerProjectSCDProfilePage.class;
+ private Shell shell;
+ private static GCCPerProjectSCDProfilePage instance;
+ private static boolean loadButtonInitialEnabled = true;
+
+ private Button bopEnabledButton;
+ private Text bopOpenFileText;
+ private Button bopLoadButton;
+ private Button sipEnabledButton;
+ private Text sipRunCommandText;
+
+ private boolean isValid = true;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.AbstractCOptionPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ // Add the profile UI contribution.
+ Group profileGroup = ControlFactory.createGroup(parent,
+ MakeUIPlugin.getResourceString(BO_PROVIDER_GROUP_LABEL), 3);
+
+ GridData gd = (GridData) profileGroup.getLayoutData();
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
+// PixelConverter converter = new PixelConverter(parent);
+// gd.heightHint = converter.convertHorizontalDLUsToPixels(DEFAULT_HEIGHT);
+ ((GridLayout) profileGroup.getLayout()).makeColumnsEqualWidth = false;
+
+ // Add bop enabled checkbox
+ bopEnabledButton = ControlFactory.createCheckBox(profileGroup,
+ MakeUIPlugin.getResourceString(BO_PROVIDER_PARSER_ENABLED_BUTTON));
+// bopEnabledButton.setFont(parent.getFont());
+ ((GridData)bopEnabledButton.getLayoutData()).horizontalSpan = 3;
+ ((GridData)bopEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
+ bopEnabledButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ handleModifyOpenFileText();
+ }
+
+ });
+
+ // load label
+ Label loadLabel = ControlFactory.createLabel(profileGroup,
+ MakeUIPlugin.getResourceString(BO_PROVIDER_OPEN_LABEL));
+ ((GridData) loadLabel.getLayoutData()).horizontalSpan = 3;
+
+ // text field
+ bopOpenFileText = ControlFactory.createTextField(profileGroup, SWT.SINGLE | SWT.BORDER);
+ bopOpenFileText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ handleModifyOpenFileText();
+ }
+ });
+
+ // browse button
+ Button browseButton = ControlFactory.createPushButton(profileGroup,
+ MakeUIPlugin.getResourceString(BO_PROVIDER_BROWSE_BUTTON));
+ ((GridData) browseButton.getLayoutData()).widthHint =
+ SWTUtil.getButtonWidthHint(browseButton);
+ browseButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleBOPBrowseButtonSelected();
+ }
+
+ private void handleBOPBrowseButtonSelected() {
+ FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
+ dialog.setText(MakeUIPlugin.getResourceString(BO_PROVIDER_OPEN_FILE_DIALOG)); //$NON-NLS-1$
+ String fileName = bopOpenFileText.getText().trim();
+ IPath filterPath;
+ if (fileName.length() == 0 && getContainer().getProject() != null) {
+ filterPath = getContainer().getProject().getLocation();
+ }
+ else {
+ IPath filePath = new Path(fileName);
+ filterPath = filePath.removeLastSegments(1).makeAbsolute();
+ }
+ dialog.setFilterPath(filterPath.toOSString());
+ String res = dialog.open();
+ if (res == null) {
+ return;
+ }
+ bopOpenFileText.setText(res);
+ }
+ });
+
+ // load button
+ bopLoadButton = ControlFactory.createPushButton(profileGroup,
+ MakeUIPlugin.getResourceString(BO_PROVIDER_LOAD_BUTTON));
+ ((GridData) bopLoadButton.getLayoutData()).widthHint =
+ SWTUtil.getButtonWidthHint(bopLoadButton);
+ bopLoadButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleBOPLoadFileButtonSelected();
+ }
+
+ });
+ bopLoadButton.setEnabled(loadButtonInitialEnabled);
+ if (getContainer().getProject() == null) { // project properties
+ bopLoadButton.setVisible(false);
+ }
+
+ ControlFactory.createSeparator(profileGroup, 3);
+
+ // si provider enabled checkbox
+ sipEnabledButton = ControlFactory.createCheckBox(profileGroup,
+ MakeUIPlugin.getResourceString(SI_PROVIDER_PARSER_ENABLED_BUTTON));
+// sipEnabledButton.setFont(parent.getFont());
+ ((GridData)sipEnabledButton.getLayoutData()).horizontalSpan = 3;
+ ((GridData)sipEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
+ sipEnabledButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+// bopLoadButton.setEnabled(sipEnabledButton.getSelection());
+ }
+
+ });
+
+ // si command label
+ Label siCommandLabel = ControlFactory.createLabel(profileGroup,
+ MakeUIPlugin.getResourceString(SI_PROVIDER_COMMAND_LABEL));
+ ((GridData) siCommandLabel.getLayoutData()).horizontalSpan = 3;
+
+ // text field
+ sipRunCommandText = ControlFactory.createTextField(profileGroup, SWT.SINGLE | SWT.BORDER);
+ //((GridData) sipRunCommandText.getLayoutData()).horizontalSpan = 2;
+ sipRunCommandText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ handleModifyRunCommandText();
+ }
+ });
+
+ // si browse button
+ Button siBrowseButton = ControlFactory.createPushButton(profileGroup,
+ MakeUIPlugin.getResourceString(SI_PROVIDER_BROWSE_BUTTON));
+ ((GridData) siBrowseButton.getLayoutData()).widthHint =
+ SWTUtil.getButtonWidthHint(browseButton);
+ siBrowseButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleSIPBrowseButtonSelected();
+ }
+
+ private void handleSIPBrowseButtonSelected() {
+ FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
+ dialog.setText(MakeUIPlugin.getResourceString(SI_PROVIDER_COMMAND_DIALOG)); //$NON-NLS-1$
+ String fileName = sipRunCommandText.getText().trim();
+ int lastSeparatorIndex = fileName.lastIndexOf(File.separator);
+ if (lastSeparatorIndex != -1) {
+ dialog.setFilterPath(fileName.substring(0, lastSeparatorIndex));
+ }
+ String res = dialog.open();
+ if (res == null) {
+ return;
+ }
+ sipRunCommandText.setText(res);
+ }
+ });
+
+
+ setControl(parent);
+ // set the shell variable; must be after setControl
+ //lock.acquire();
+ synchronized (lock) {
+ shell = getShell();
+ instance = this;
+ }
+ //lock.release();
+ initializeValues();
+ }
+
+ /**
+ *
+ */
+ protected void handleModifyOpenFileText() {
+ String fileName = bopOpenFileText.getText().trim();
+ bopLoadButton.setEnabled(bopEnabledButton.getSelection() &&
+ fileName.length() > 0 &&
+ new File(fileName).exists());
+ }
+
+ /**
+ *
+ */
+ protected void handleModifyRunCommandText() {
+ String cmd = sipRunCommandText.getText().trim();
+ isValid = (cmd.length() > 0) ? true : false;
+
+ getContainer().updateContainer();
+ }
+
+ /**
+ *
+ */
+ private void initializeValues() {
+ bopEnabledButton.setSelection(getBuildInfo().isBuildOutputParserEnabled());
+ bopOpenFileText.setText(getBuildInfo().getBuildOutputFilePath());
+ sipEnabledButton.setSelection(getBuildInfo().isProviderOutputParserEnabled(providerId));
+ sipRunCommandText.setText(getBuildInfo().getProviderRunCommand(providerId));
+ }
+
+ private void handleBOPLoadFileButtonSelected() {
+ loadButtonInitialEnabled = false;
+ bopLoadButton.setEnabled(false);
+
+ // populate buildInfo to be used by the reader job
+ populateBuildInfo(getBuildInfo(), null);
+ IProject project = getContainer().getProject();
+ Job readerJob = new BuildOutputReaderJob(project, getBuildInfo());
+ readerJob.setPriority(Job.LONG);
+ readerJob.addJobChangeListener(new JobChangeAdapter() {
+
+ public void done(IJobChangeEvent event) {
+ //lock.acquire();
+ synchronized (lock) {
+ if (!instance.shell.isDisposed()) {
+ instance.shell.getDisplay().asyncExec(new Runnable() {
+
+ public void run() {
+ if (!instance.shell.isDisposed()) {
+ instance.bopLoadButton.setEnabled(instance.bopEnabledButton.getSelection());
+ }
+ loadButtonInitialEnabled = instance.bopEnabledButton.getSelection();//true;
+ }
+
+ });
+ }
+ else {
+ loadButtonInitialEnabled = instance.bopEnabledButton.getSelection();//true;
+ }
+ }
+ //lock.release();
+ }
+
+ });
+ readerJob.schedule();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#isValid()
+ */
+ public boolean isValid() {
+ return isValid;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#getErrorMessage()
+ */
+ public String getErrorMessage() {
+ return (isValid) ? null : MakeUIPlugin.getResourceString(SI_PROVIDER_COMMAND_ERROR_MESSAGE);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.AbstractCOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void performApply(IProgressMonitor monitor) throws CoreException {
+ IProject project = getContainer().getProject();
+ // Create new build info in case of new C++ project wizard
+ IScannerConfigBuilderInfo2 buildInfo = createBuildInfo(project);
+
+ if (buildInfo != null) {
+ populateBuildInfo(buildInfo, monitor);
+ buildInfo.store();
+ }
+ }
+
+ private void populateBuildInfo(IScannerConfigBuilderInfo2 buildInfo, IProgressMonitor monitor) {
+ buildInfo.setBuildOutputFileActionEnabled(true);
+ buildInfo.setBuildOutputFilePath(bopOpenFileText.getText().trim());
+ buildInfo.setBuildOutputParserEnabled(bopEnabledButton.getSelection());
+
+ buildInfo.setProviderOutputParserEnabled(providerId, sipEnabledButton.getSelection());
+ buildInfo.setProviderRunCommand(providerId, sipRunCommandText.getText().trim());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.AbstractCOptionPage#performDefaults()
+ */
+ public void performDefaults() {
+ // Create buildInfo with defaults
+ IScannerConfigBuilderInfo2 buildInfo = createBuildInfo();
+
+ restoreFromBuildinfo(buildInfo);
+ }
+
+ private void restoreFromBuildinfo(IScannerConfigBuilderInfo2 buildInfo) {
+ bopOpenFileText.setText(buildInfo.getBuildOutputFilePath());
+ bopEnabledButton.setSelection(buildInfo.isBuildOutputParserEnabled());
+
+ sipEnabledButton.setSelection(buildInfo.isProviderOutputParserEnabled(providerId));
+ sipRunCommandText.setText(buildInfo.getProviderRunCommand(providerId));
+ }
+
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/ManageDefinedSymbolsDialog.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/ManageDefinedSymbolsDialog.java
deleted file mode 100644
index f645a81cd00..00000000000
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/ManageDefinedSymbolsDialog.java
+++ /dev/null
@@ -1,537 +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.make.ui.dialogs;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.eclipse.cdt.internal.ui.util.SWTUtil;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigUtil;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
-import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathInfo;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoCollector;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
-import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
-import org.eclipse.cdt.make.internal.ui.MessageLine;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Manage defined symbols dialog
- *
- * @author vhirsl
- */
-public class ManageDefinedSymbolsDialog extends Dialog {
- private static final String PREF_SYMBOLS = "ScannerSymbols"; //$NON-NLS-1$
-
- private static final String PREFIX = "ManageDefinedSymbolsDialog"; //$NON-NLS-1$
- private static final String DIALOG_TITLE = PREFIX + ".title"; //$NON-NLS-1$
- private static final String USER_GROUP = PREFIX + ".userGroup.title"; //$NON-NLS-1$
- private static final String NEW = "BuildPropertyCommon.label.new"; //$NON-NLS-1$
- private static final String EDIT = "BuildPropertyCommon.label.edit"; //$NON-NLS-1$
- private static final String REMOVE = "BuildPropertyCommon.label.remove"; //$NON-NLS-1$
- private static final String UP = "BuildPropertyCommon.label.up"; //$NON-NLS-1$
- private static final String DOWN = "BuildPropertyCommon.label.down"; //$NON-NLS-1$
-
- private static final String BROWSE = "BuildPathInfoBlock.browse"; //$NON-NLS-1$
- private static final String SYMBOL_TITLE = BROWSE + ".symbol"; //$NON-NLS-1$
- private static final String EDIT_SYMBOL_TITLE = BROWSE + ".symbol.edit"; //$NON-NLS-1$
- private static final String SYMBOL_LABEL = BROWSE + ".symbol.label"; //$NON-NLS-1$
-
- private static final String DISCOVERED_GROUP = PREFIX + ".discoveredGroup.title"; //$NON-NLS-1$
-
- private static final String DISC_COMMON_PREFIX = "ManageScannerConfigDialogCommon"; //$NON-NLS-1$
- private static final String SELECTED_LABEL = DISC_COMMON_PREFIX + ".discoveredGroup.selected.label"; //$NON-NLS-1$
- private static final String REMOVED_LABEL = DISC_COMMON_PREFIX + ".discoveredGroup.removed.label"; //$NON-NLS-1$
- private static final String REMOVE_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.remove.label"; //$NON-NLS-1$
- private static final String RESTORE_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.restore.label"; //$NON-NLS-1$
- private static final String DELETE_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.delete.label"; //$NON-NLS-1$
- private static final String DELETE_ALL_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.deleteAll.label"; //$NON-NLS-1$
-
- private static final int PROJECT_LIST_MULTIPLIER = 15;
- private static final int INITIAL_LIST_WIDTH = 40;
-
- private static final int ACTIVE = 0;
- private static final int REMOVED = 1;
-
- private static final int DO_REMOVE = 0;
- private static final int DO_RESTORE = 1;
-
- boolean alreadyCreated; // Set when dialog is created for the first time (vs. reopened)
- private ArrayList returnSymbols;
- private ArrayList deletedDiscoveredSymbols;
- private LinkedHashMap discoveredSymbols;
- private LinkedHashMap workingDiscoveredSymbols; // working copy of discoveredSymbols, until either OK or CANCEL is pressed
- private boolean fDirty;
- private boolean fWorkingDirty;
-
- private ICOptionContainer fContainer;
- private IProject fProject;
- private Shell fShell;
- private MessageLine fStatusLine;
-
- private Group discoveredGroup;
- private Label selectedLabel;
- private Label removedLabel;
- private List discActiveList;
- private List discRemovedList;
- private Button removeDiscSymbol;
- private Button restoreDiscSymbol;
- private Button deleteDiscSymbol;
- private Button deleteAllDiscSymbols;
-
- /**
- * @param parentShell
- */
- protected ManageDefinedSymbolsDialog(Shell parentShell, ICOptionContainer container) {
- super(parentShell);
- fShell = parentShell;
- fContainer = container;
- fProject = fContainer.getProject();
- IDiscoveredPathInfo scanInfo;
- if (fProject != null) {
- try {
- scanInfo = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject);
- } catch (CoreException e) {
- scanInfo = new DiscoveredPathInfo(fProject);
- }
- }
- else {
- scanInfo = new DiscoveredPathInfo(fProject);
- }
- discoveredSymbols = scanInfo.getSymbolMap();
- setDirty(false);
- fDirty = false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
- */
- protected void configureShell(Shell newShell) {
- newShell.setText(getTitle(DIALOG_TITLE));
- super.configureShell(newShell);
- }
-
- /**
- * @return
- */
- private String getTitle(String title) {
- return MakeUIPlugin.getResourceString(title);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- protected Control createDialogArea(Composite parent) {
- setDirty(false);
- Composite composite = (Composite) super.createDialogArea(parent);
- ((GridLayout) composite.getLayout()).numColumns = 3;
- initializeDialogUnits(composite);
-
- // create message line
- fStatusLine = new MessageLine(composite);
- fStatusLine.setAlignment(SWT.LEFT);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 3;
-// gd.widthHint = convertWidthInCharsToPixels(50);
- fStatusLine.setLayoutData(gd);
- fStatusLine.setMessage(getTitle(DIALOG_TITLE));
-
- createOptionsControls(composite);
- createDiscoveredControls(composite);
-
- setListContents();
- discActiveList.select(0);
- enableDiscoveredButtons();
-
- return composite;
- }
-
- /**
- *
- */
- private void setListContents() {
- workingDiscoveredSymbols = new LinkedHashMap(discoveredSymbols);
-
- discActiveList.setItems(getDiscDefinedSymbols(workingDiscoveredSymbols, ACTIVE));
- discRemovedList.setItems(getDiscDefinedSymbols(workingDiscoveredSymbols, REMOVED));
- }
-
- /**
- * @param discoveredPaths
- * @return
- */
- private String[] getDiscDefinedSymbols(Map dSymbols, int type) {
- ArrayList aSymbols = new ArrayList();
- for (Iterator i = dSymbols.keySet().iterator(); i.hasNext(); ) {
- String symbol = (String) i.next();
- SymbolEntry values = (SymbolEntry) dSymbols.get(symbol);
- java.util.List aValues = (type == ACTIVE ? values.getActiveRaw() : values.getRemovedRaw());
- aSymbols.addAll(aValues);
- }
- return (String[]) aSymbols.toArray(new String[aSymbols.size()]);
- }
-
- private String[] getIncludes(Preferences prefs) {
- String syms = prefs.getString(PREF_SYMBOLS);
- return parseStringToList(syms);
- }
-
- private String[] parseStringToList(String syms) {
- if (syms != null && syms.length() > 0) {
- StringTokenizer tok = new StringTokenizer(syms, ";"); //$NON-NLS-1$
- ArrayList list = new ArrayList(tok.countTokens());
- while (tok.hasMoreElements()) {
- list.add(tok.nextToken());
- }
- return (String[]) list.toArray(new String[list.size()]);
- }
- return new String[0];
- }
-
- /**
- * @param composite
- */
- private void createOptionsControls(Composite composite) {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * @param composite
- */
- private void createDiscoveredControls(Composite composite) {
- // Create group
- discoveredGroup = ControlFactory.createGroup(composite, getTitle(DISCOVERED_GROUP), 3);
- ((GridData) discoveredGroup.getLayoutData()).horizontalSpan = 3;
- ((GridData) discoveredGroup.getLayoutData()).grabExcessHorizontalSpace = true;
-
- // Create composite
-// Composite c1 = ControlFactory.createComposite(discoveredGroup, 1);
- Composite c1 = discoveredGroup;
-
- // Create label Selected:
- selectedLabel = ControlFactory.createLabel(c1, getTitle(SELECTED_LABEL));
- ((GridData) selectedLabel.getLayoutData()).horizontalSpan = 1;
-
- // Add a dummy label
- ControlFactory.createLabel(discoveredGroup, "");//$NON-NLS-1$
-
- // Create label Removed:
- removedLabel = ControlFactory.createLabel(c1, getTitle(REMOVED_LABEL));
- ((GridData) removedLabel.getLayoutData()).horizontalSpan = 1;
-
- // Create list
- discActiveList = new List(c1, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
- discActiveList.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- discRemovedList.deselectAll();
- enableDiscoveredButtons();
- }
- });
- // Make it occupy the first column
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.grabExcessHorizontalSpace = true;
- gd.horizontalSpan = 1;
- gd.heightHint = getDefaultFontHeight(discActiveList, PROJECT_LIST_MULTIPLIER);
- gd.widthHint = convertWidthInCharsToPixels(INITIAL_LIST_WIDTH);
- discActiveList.setLayoutData(gd);
-
- // Create buttons
- // Create a composite for the buttons
- Composite pathButtonComp = ControlFactory.createComposite(discoveredGroup, 1);
-
- // Add the buttons
- removeDiscSymbol = ControlFactory.createPushButton(pathButtonComp, getTitle(REMOVE_DISCOVERED));
- removeDiscSymbol.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleRemoveRestoreDiscSymbol(DO_REMOVE);
- }
- });
- removeDiscSymbol.setEnabled(true);
- SWTUtil.setButtonDimensionHint(removeDiscSymbol);
-
- restoreDiscSymbol = ControlFactory.createPushButton(pathButtonComp, getTitle(RESTORE_DISCOVERED));
- restoreDiscSymbol.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleRemoveRestoreDiscSymbol(DO_RESTORE);
- }
- });
- restoreDiscSymbol.setEnabled(true);
- SWTUtil.setButtonDimensionHint(restoreDiscSymbol);
-
- Label sep = ControlFactory.createSeparator(pathButtonComp, 1);
-
- deleteDiscSymbol = ControlFactory.createPushButton(pathButtonComp, getTitle(DELETE_DISCOVERED));
- deleteDiscSymbol.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleDeleteDiscSymbol();
- }
- });
- deleteDiscSymbol.setEnabled(true);
- SWTUtil.setButtonDimensionHint(deleteDiscSymbol);
-
- deleteAllDiscSymbols = ControlFactory.createPushButton(pathButtonComp, getTitle(DELETE_ALL_DISCOVERED));
- deleteAllDiscSymbols.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleDeleteAllDiscSymbols();
- }
- });
- deleteAllDiscSymbols.setEnabled(true);
- SWTUtil.setButtonDimensionHint(deleteAllDiscSymbols);
-
- // Create composite
-// Composite c2 = ControlFactory.createComposite(discoveredGroup, 1);
- Composite c2 = discoveredGroup;
-
- // Create list
- discRemovedList = new List(c2, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
- discRemovedList.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- discActiveList.deselectAll();
- enableDiscoveredButtons();
- }
- });
- // Make it occupy the first column
- GridData gd2 = new GridData(GridData.FILL_BOTH);
- gd2.grabExcessHorizontalSpace = true;
- gd2.horizontalSpan = 1;
- gd2.heightHint = getDefaultFontHeight(discRemovedList, PROJECT_LIST_MULTIPLIER);
- gd2.widthHint = convertWidthInCharsToPixels(INITIAL_LIST_WIDTH);
- discRemovedList.setLayoutData(gd2);
- }
-
- /**
- *
- */
- protected void handleRemoveRestoreDiscSymbol(int type) {
- if (workingDiscoveredSymbols != null) {
- List discList = discRemovedList;
- List discOtherList = discActiveList;
- boolean newStatus = true; // active
- if (type == DO_REMOVE) {
- discList = discActiveList;
- discOtherList = discRemovedList;
- newStatus = false; // removed
- }
-
- int id = discList.getSelectionIndex();
- if (id != -1) {
- String symbol = discList.getItem(id);
- String key = ScannerConfigUtil.getSymbolKey(symbol);
- String value = ScannerConfigUtil.getSymbolValue(symbol);
- // find it in the discoveredSymbols Map of SymbolEntries
- SymbolEntry se = (SymbolEntry) workingDiscoveredSymbols.get(key);
- if (se != null) {
- se = new SymbolEntry(se); // deep copy
- se.replace(value, newStatus);
- workingDiscoveredSymbols.put(key, se);
- // update UI
- discActiveList.setItems(getDiscDefinedSymbols(workingDiscoveredSymbols, ACTIVE));
- discRemovedList.setItems(getDiscDefinedSymbols(workingDiscoveredSymbols, REMOVED));
- discOtherList.setSelection(discOtherList.indexOf(symbol));
- enableDiscoveredButtons();
- setDirty(true);
- }
- else {
- //TODO VMIR generate an error
- }
- }
- }
- }
-
- /**
- *
- */
- protected void handleDeleteDiscSymbol() {
- deleteDiscSymbol(REMOVED);
- deleteDiscSymbol(ACTIVE);
- }
-
- private void deleteDiscSymbol(int type) {
- List discList = discRemovedList;
- if (type == ACTIVE) {
- discList = discActiveList;
- }
- int id = discList.getSelectionIndex();
- if (id >= 0) {
- String symbol = discList.getItem(id);
- // add it to the deleted list
- if (deletedDiscoveredSymbols == null) {
- deletedDiscoveredSymbols = new ArrayList();
- }
- deletedDiscoveredSymbols.add(symbol);
-
- // remove it from the Map of SymbolEntries
- ScannerConfigUtil.removeSymbolEntryValue(symbol, workingDiscoveredSymbols);
-
- int items = discList.getItemCount();
- discList.setItems(getDiscDefinedSymbols(workingDiscoveredSymbols, type));
- if (items > 0) {
- if (id >= items) {
- id = items - 1;
- }
- discList.setSelection(id);
- enableDiscoveredButtons();
- setDirty(true);
- }
- }
- }
-
- /**
- *
- */
- protected void handleDeleteAllDiscSymbols() {
- ScannerInfoCollector.getInstance().deleteAllSymbols(fProject);
- workingDiscoveredSymbols.clear();
- discActiveList.setItems(getDiscDefinedSymbols(workingDiscoveredSymbols, ACTIVE));
- discRemovedList.setItems(getDiscDefinedSymbols(workingDiscoveredSymbols, REMOVED));
- enableDiscoveredButtons();
- setDirty(true);
- }
-
- /**
- *
- */
- protected void enableDiscoveredButtons() {
- discoveredGroup.setEnabled(fProject != null);
- selectedLabel.setEnabled(fProject != null);
- discActiveList.setEnabled(fProject != null);
- removedLabel.setEnabled(fProject != null);
- discRemovedList.setEnabled(fProject != null);
-
- int activeItems = discActiveList.getItemCount();
- int activeSeclection = discActiveList.getSelectionIndex();
- int removedItems = discRemovedList.getItemCount();
- int removedSelection = discRemovedList.getSelectionIndex();
- // To maintain the proper TAB order of enabled buttons
- if (activeItems > 0 && activeSeclection >= 0) {
- removeDiscSymbol.setEnabled(activeItems > 0 && activeSeclection >= 0);
- restoreDiscSymbol.setEnabled(removedItems > 0 && removedSelection >= 0);
- }
- else {
- restoreDiscSymbol.setEnabled(removedItems > 0 && removedSelection >= 0);
- removeDiscSymbol.setEnabled(activeItems > 0 && activeSeclection >= 0);
- }
- deleteDiscSymbol.setEnabled((activeItems > 0 && activeSeclection >= 0) ||
- (removedItems > 0 && removedSelection >= 0));
- deleteAllDiscSymbols.setEnabled(activeItems > 0 || removedItems > 0);
- }
-
- /**
- * Get the defualt widget height for the supplied control.
- * @return int
- * @param control - the control being queried about fonts
- * @param lines - the number of lines to be shown on the table.
- */
- private static int getDefaultFontHeight(Control control, int lines) {
- FontData[] viewerFontData = control.getFont().getFontData();
- int fontHeight = 10;
-
- //If we have no font data use our guess
- if (viewerFontData.length > 0)
- fontHeight = viewerFontData[0].getHeight();
- return lines * fontHeight;
- }
-
- /**
- * @return
- */
- public String[] getManagedSymbols() {
- if (returnSymbols == null) {
- return new String[0];
- }
- return (String[]) returnSymbols.toArray(new String[returnSymbols.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
- */
- protected void buttonPressed(int buttonId) {
- if (IDialogConstants.OK_ID == buttonId) {
- // Store discovered part
- discoveredSymbols = workingDiscoveredSymbols;
- // Return sum of user and active discovered paths
- returnSymbols = new ArrayList(discActiveList.getItemCount());
- returnSymbols.addAll(new ArrayList(Arrays.asList(discActiveList.getItems())));
-
- fDirty = fWorkingDirty;
- }
- else if (IDialogConstants.CANCEL_ID == buttonId) {
- deletedDiscoveredSymbols = null;
- workingDiscoveredSymbols = null;
- setDirty(false);
- }
- super.buttonPressed(buttonId);
- }
-
- private void setDirty(boolean dirty) {
- fWorkingDirty = dirty;
- }
-
- /**
- * Called by BuildPathInfoBlock.performApply
- * @param info
- * @return boolean - true if changed
- */
- public boolean saveTo(IDiscoveredPathInfo info) {
- if (fDirty || (fProject == null && fContainer.getProject() != null)) {// New Standard Make project wizard
- info.setSymbolMap(discoveredSymbols);
- // remove deleted symbols from discovered SC
- if (deletedDiscoveredSymbols != null) {
- for (Iterator i = deletedDiscoveredSymbols.iterator(); i.hasNext(); ) {
- ScannerInfoCollector.getInstance().deleteSymbol(fProject, (String) i.next());
- }
- deletedDiscoveredSymbols = null;
- }
- }
- setDirty(false);
- boolean rc = fDirty;
- fDirty = false;
- return rc;
- }
-
- /**
- * Called by BuildPathInfoBlock.performDefaults
- */
- public void restore() {
- if (fProject != null) {
- // remove discovered symbols
- ScannerInfoCollector.getInstance().deleteAllSymbols(fProject);
- }
- discoveredSymbols = new LinkedHashMap();
- deletedDiscoveredSymbols = null;
- fDirty = true;
- }
-}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/ManageIncludePathsDialog.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/ManageIncludePathsDialog.java
deleted file mode 100644
index 4c3790898ec..00000000000
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/ManageIncludePathsDialog.java
+++ /dev/null
@@ -1,598 +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.make.ui.dialogs;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.StringTokenizer;
-
-import org.eclipse.cdt.internal.ui.util.SWTUtil;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
-import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathInfo;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoCollector;
-import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
-import org.eclipse.cdt.make.internal.ui.MessageLine;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Manage include paths dialog
- *
- * @author vhirsl
- */
-public class ManageIncludePathsDialog extends Dialog {
- private static final String PREF_INCLUDES = "ScannerIncludes"; //$NON-NLS-1$
-
- private static final String PREFIX = "ManageIncludePathsDialog"; //$NON-NLS-1$
- private static final String DIALOG_TITLE = PREFIX + ".title"; //$NON-NLS-1$
- private static final String USER_GROUP = PREFIX + ".userGroup.title"; //$NON-NLS-1$
- private static final String NEW = "BuildPropertyCommon.label.new"; //$NON-NLS-1$
- private static final String EDIT = "BuildPropertyCommon.label.edit"; //$NON-NLS-1$
- private static final String REMOVE = "BuildPropertyCommon.label.remove"; //$NON-NLS-1$
- private static final String UP = "BuildPropertyCommon.label.up"; //$NON-NLS-1$
- private static final String DOWN = "BuildPropertyCommon.label.down"; //$NON-NLS-1$
-
- private static final String BROWSE = "BuildPathInfoBlock.browse"; //$NON-NLS-1$
- private static final String PATH_TITLE = BROWSE + ".path"; //$NON-NLS-1$
- private static final String EDIT_PATH_TITLE = BROWSE + ".path.edit"; //$NON-NLS-1$
- private static final String PATH_LABEL = BROWSE + ".path.label"; //$NON-NLS-1$
-
- private static final String DISCOVERED_GROUP = PREFIX + ".discoveredGroup.title"; //$NON-NLS-1$
-
- private static final String DISC_COMMON_PREFIX = "ManageScannerConfigDialogCommon"; //$NON-NLS-1$
- private static final String SELECTED_LABEL = DISC_COMMON_PREFIX + ".discoveredGroup.selected.label"; //$NON-NLS-1$
- private static final String REMOVED_LABEL = DISC_COMMON_PREFIX + ".discoveredGroup.removed.label"; //$NON-NLS-1$
- private static final String UP_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.up.label"; //$NON-NLS-1$
- private static final String DOWN_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.down.label"; //$NON-NLS-1$
- private static final String REMOVE_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.remove.label"; //$NON-NLS-1$
- private static final String RESTORE_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.restore.label"; //$NON-NLS-1$
- private static final String DELETE_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.delete.label"; //$NON-NLS-1$
- private static final String DELETE_ALL_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.deleteAll.label"; //$NON-NLS-1$
-
- private static final int PROJECT_LIST_MULTIPLIER = 15;
- private static final int INITIAL_LIST_WIDTH = 50;
-
- private static final int ACTIVE = 0;
- private static final int REMOVED = 1;
-
- private static final int DO_REMOVE = 0;
- private static final int DO_RESTORE = 1;
-
- private static final int DISC_UP = 0;
- private static final int DISC_DOWN = 1;
-
- private ArrayList returnPaths;
- private ArrayList deletedDiscoveredPaths;
- private LinkedHashMap discoveredPaths;
- private LinkedHashMap workingDiscoveredPaths; // working copy of discoveredPaths, until either OK or CANCEL is pressed
- private boolean fDirty;
- private boolean fWorkingDirty;
-
- private ICOptionContainer fContainer;
- private IProject fProject;
- private Shell fShell;
- private MessageLine fStatusLine;
-
- private Group discoveredGroup;
- private Label selectedLabel;
- private Label removedLabel;
- private List discActiveList;
- private List discRemovedList;
- private Button upDiscPath;
- private Button downDiscPath;
- private Button removeDiscPath;
- private Button restoreDiscPath;
- private Button deleteDiscPath;
- private Button deleteAllDiscPaths;
-
- /**
- * @param parentShell
- */
- protected ManageIncludePathsDialog(Shell parentShell, ICOptionContainer container) {
- super(parentShell);
- fShell = parentShell;
- fContainer = container;
- fProject = fContainer.getProject();
- IDiscoveredPathInfo scanInfo;
- if (fProject != null) {
- try {
- scanInfo = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject);
- } catch (CoreException e) {
- scanInfo = new DiscoveredPathInfo(fProject);
- }
- }
- else {
- scanInfo = new DiscoveredPathInfo(fProject);
- }
- discoveredPaths = scanInfo.getIncludeMap();
- setDirty(false);
- fDirty = false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
- */
- protected void configureShell(Shell newShell) {
- newShell.setText(getTitle(DIALOG_TITLE));
- super.configureShell(newShell);
- }
-
- /**
- * @return
- */
- private String getTitle(String title) {
- return MakeUIPlugin.getResourceString(title);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- ((GridLayout) composite.getLayout()).numColumns = 3;
- initializeDialogUnits(composite);
-
- // create message line
- fStatusLine = new MessageLine(composite);
- fStatusLine.setAlignment(SWT.LEFT);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 3;
-// gd.widthHint = convertWidthInCharsToPixels(50);
- fStatusLine.setLayoutData(gd);
- fStatusLine.setMessage(getTitle(DIALOG_TITLE));
-
- createOptionsControls(composite);
- createDiscoveredControls(composite);
-
- setListContents();
- discActiveList.select(0);
- discActiveList.setFocus();
- enableDiscoveredButtons();
-
- return composite;
- }
-
- /**
- *
- */
- private void setListContents() {
- workingDiscoveredPaths = new LinkedHashMap(discoveredPaths);
-
- discActiveList.setItems(getDiscIncludePaths(workingDiscoveredPaths, ACTIVE));
- discRemovedList.setItems(getDiscIncludePaths(workingDiscoveredPaths, REMOVED));
- }
-
- /**
- * @param discoveredPaths
- * @return
- */
- private String[] getDiscIncludePaths(LinkedHashMap dPaths, int type) {
- ArrayList aPaths = new ArrayList();
- boolean compareValue = (type == ACTIVE ? false : true);
- for (Iterator i = dPaths.keySet().iterator(); i.hasNext(); ) {
- String path = (String) i.next();
- if (((Boolean) dPaths.get(path)).booleanValue() == compareValue) {
- aPaths.add(path);
- }
- }
- return (String[]) aPaths.toArray(new String[aPaths.size()]);
- }
-
- private String[] getIncludes(Preferences prefs) {
- String syms = prefs.getString(PREF_INCLUDES);
- return parseStringToList(syms);
- }
-
- private String[] parseStringToList(String syms) {
- if (syms != null && syms.length() > 0) {
- StringTokenizer tok = new StringTokenizer(syms, ";"); //$NON-NLS-1$
- ArrayList list = new ArrayList(tok.countTokens());
- while (tok.hasMoreElements()) {
- list.add(tok.nextToken());
- }
- return (String[]) list.toArray(new String[list.size()]);
- }
- return new String[0];
- }
-
- /**
- * @param composite
- */
- private void createOptionsControls(Composite composite) {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * @param composite
- */
- private void createDiscoveredControls(Composite composite) {
- // Create group
- discoveredGroup = ControlFactory.createGroup(composite, getTitle(DISCOVERED_GROUP), 3);
- ((GridData) discoveredGroup.getLayoutData()).horizontalSpan = 3;
- ((GridData) discoveredGroup.getLayoutData()).grabExcessHorizontalSpace = true;
-
- // Create label Selected:
- selectedLabel = ControlFactory.createLabel(discoveredGroup, getTitle(SELECTED_LABEL));
- ((GridData) selectedLabel.getLayoutData()).horizontalSpan = 1;
-
- // Add a dummy label
- ControlFactory.createLabel(discoveredGroup, "");//$NON-NLS-1$
-
- // Create label Removed:
- removedLabel = ControlFactory.createLabel(discoveredGroup, getTitle(REMOVED_LABEL));
- ((GridData) removedLabel.getLayoutData()).horizontalSpan = 1;
-
- // Create list
- discActiveList = new List(discoveredGroup, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
- discActiveList.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- discRemovedList.deselectAll();
- enableDiscoveredButtons();
- }
- });
- // Make it occupy the first column
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.grabExcessHorizontalSpace = true;
- gd.horizontalSpan = 1;
- gd.heightHint = getDefaultFontHeight(discActiveList, PROJECT_LIST_MULTIPLIER);
- gd.widthHint = convertWidthInCharsToPixels(INITIAL_LIST_WIDTH);
- discActiveList.setLayoutData(gd);
-
- // Create buttons
- // Create a composite for the buttons
- Composite pathButtonComp = ControlFactory.createComposite(discoveredGroup, 1);
-
- // Add the buttons
- upDiscPath = ControlFactory.createPushButton(pathButtonComp, getTitle(UP_DISCOVERED));
- upDiscPath.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleUpDownDiscPath(DISC_UP);
- }
- });
- upDiscPath.setEnabled(true);
- SWTUtil.setButtonDimensionHint(upDiscPath);
-
- downDiscPath = ControlFactory.createPushButton(pathButtonComp, getTitle(DOWN_DISCOVERED));
- downDiscPath.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleUpDownDiscPath(DISC_DOWN);
- }
- });
- downDiscPath.setEnabled(true);
- SWTUtil.setButtonDimensionHint(downDiscPath);
-
- removeDiscPath = ControlFactory.createPushButton(pathButtonComp, getTitle(REMOVE_DISCOVERED));
- removeDiscPath.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleRemoveRestoreDiscPath(DO_REMOVE);
- }
- });
- removeDiscPath.setEnabled(true);
- SWTUtil.setButtonDimensionHint(removeDiscPath);
-
- restoreDiscPath = ControlFactory.createPushButton(pathButtonComp, getTitle(RESTORE_DISCOVERED));
- restoreDiscPath.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleRemoveRestoreDiscPath(DO_RESTORE);
- }
- });
- restoreDiscPath.setEnabled(true);
- SWTUtil.setButtonDimensionHint(restoreDiscPath);
-
- Label sep = ControlFactory.createSeparator(pathButtonComp, 1);
-
- deleteDiscPath = ControlFactory.createPushButton(pathButtonComp, getTitle(DELETE_DISCOVERED));
- deleteDiscPath.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleDeleteDiscPath();
- }
- });
- deleteDiscPath.setEnabled(true);
- SWTUtil.setButtonDimensionHint(deleteDiscPath);
-
- deleteAllDiscPaths = ControlFactory.createPushButton(pathButtonComp, getTitle(DELETE_ALL_DISCOVERED));
- deleteAllDiscPaths.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleDeleteAllDiscPath();
- }
- });
- deleteAllDiscPaths.setEnabled(true);
- SWTUtil.setButtonDimensionHint(deleteAllDiscPaths);
-
- // Create list
- discRemovedList = new List(discoveredGroup, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
- discRemovedList.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- discActiveList.deselectAll();
- enableDiscoveredButtons();
- }
- });
- // Make it occupy the first column
- GridData gd2 = new GridData(GridData.FILL_BOTH);
- gd2.grabExcessHorizontalSpace = true;
- gd2.horizontalSpan = 1;
- gd2.heightHint = getDefaultFontHeight(discRemovedList, PROJECT_LIST_MULTIPLIER);
- gd2.widthHint = convertWidthInCharsToPixels(INITIAL_LIST_WIDTH);
- discRemovedList.setLayoutData(gd2);
- }
-
- /**
- * @param direction (DISC_UP or DISC_DOWN)
- */
- protected void handleUpDownDiscPath(int direction) {
- int delta = (direction == DISC_UP) ? -1 : 1;
- List selectedList;
- boolean removed;
- int selectedSet;
- if (discActiveList.getSelectionIndex() == -1) {
- selectedList = discRemovedList;
- removed = true;
- selectedSet = REMOVED;
- }
- else {
- selectedList = discActiveList;
- removed = false;
- selectedSet = ACTIVE;
- }
- int selectedItem = selectedList.getFocusIndex();
- String selected = selectedList.getItem(selectedItem);
- ArrayList pathKeyList = new ArrayList(workingDiscoveredPaths.keySet());
- int curIndex = pathKeyList.indexOf(selected);
- int otherIndex = curIndex + delta;
- boolean found = false;
- for (; otherIndex >= 0 && otherIndex < pathKeyList.size(); otherIndex+=delta) {
- Boolean val = (Boolean) workingDiscoveredPaths.get(pathKeyList.get(otherIndex));
- if (val != null && val.booleanValue() == removed) {
- found = true;
- break;
- }
- }
- if (found) {
- // swap the entries in the working copy
- String temp = (String) pathKeyList.get(curIndex);
- pathKeyList.add(curIndex, pathKeyList.get(otherIndex));
- pathKeyList.add(otherIndex, temp);
-
- LinkedHashMap newWorkingDiscoveredPaths = new LinkedHashMap(workingDiscoveredPaths.size());
- for (Iterator i = pathKeyList.iterator(); i.hasNext(); ) {
- String key = (String) i.next();
- newWorkingDiscoveredPaths.put(key, workingDiscoveredPaths.get(key));
- }
- workingDiscoveredPaths = newWorkingDiscoveredPaths;
- // update UI
- selectedList.setItems(getDiscIncludePaths(workingDiscoveredPaths, selectedSet));
- selectedList.setSelection(selectedItem + delta);
- selectedList.setFocus();
- enableDiscoveredButtons();
- setDirty(true);
- }
- }
-
- /**
- *
- */
- protected void handleRemoveRestoreDiscPath(int type) {
- if (workingDiscoveredPaths != null) {
- List discList = discRemovedList;
- List discOtherList = discActiveList;
- boolean compareValue = true; // removed
- if (type == DO_REMOVE) {
- discList = discActiveList;
- discOtherList = discRemovedList;
- compareValue = false;
- }
-
- int id = discList.getSelectionIndex();
- if (id != -1) {
- String path = discList.getItem(id);
- // find it in the discoveredPaths LinkedHashMap
- Boolean value = (Boolean) workingDiscoveredPaths.get(path);
- if (value != null) {
- if (value.booleanValue() == compareValue) {
- workingDiscoveredPaths.put(path, Boolean.valueOf(!compareValue));
- // update UI
- discActiveList.setItems(getDiscIncludePaths(workingDiscoveredPaths, ACTIVE));
- discRemovedList.setItems(getDiscIncludePaths(workingDiscoveredPaths, REMOVED));
- discOtherList.setSelection(discOtherList.indexOf(path));
- enableDiscoveredButtons();
- setDirty(true);
- }
- }
- }
- }
- }
-
- /**
- *
- */
- protected void handleDeleteDiscPath() {
- deleteDiscPath(REMOVED);
- deleteDiscPath(ACTIVE);
- }
-
- /**
- * @param discList
- * @param type
- */
- private void deleteDiscPath(int type) {
- List discList = discRemovedList;
- if (type == ACTIVE) {
- discList = discActiveList;
- }
- int id = discList.getSelectionIndex();
- if (id >= 0) {
- String path = discList.getItem(id);
- // add it to the deleted list
- if (deletedDiscoveredPaths == null) {
- deletedDiscoveredPaths = new ArrayList();
- }
- deletedDiscoveredPaths.add(path);
-
- workingDiscoveredPaths.remove(path);
- discList.setItems(getDiscIncludePaths(workingDiscoveredPaths, type));
- int items = discList.getItemCount();
- if (items > 0) {
- if (id >= items) {
- id = items - 1;
- }
- discList.setSelection(id);
- enableDiscoveredButtons();
- setDirty(true);
- }
- }
- }
-
- /**
- *
- */
- protected void handleDeleteAllDiscPath() {
- ScannerInfoCollector.getInstance().deleteAllPaths(fProject);
- workingDiscoveredPaths.clear();
- discActiveList.setItems(getDiscIncludePaths(workingDiscoveredPaths, ACTIVE));
- discRemovedList.setItems(getDiscIncludePaths(workingDiscoveredPaths, REMOVED));
- enableDiscoveredButtons();
- setDirty(true);
- }
-
- /**
- *
- */
- protected void enableDiscoveredButtons() {
- discoveredGroup.setEnabled(fProject != null);
- selectedLabel.setEnabled(fProject != null);
- discActiveList.setEnabled(fProject != null);
- removedLabel.setEnabled(fProject != null);
- discRemovedList.setEnabled(fProject != null);
-
- int activeItems = discActiveList.getItemCount();
- int activeSelection = discActiveList.getSelectionIndex();
- int removedItems = discRemovedList.getItemCount();
- int removedSelection = discRemovedList.getSelectionIndex();
- // To maintain the proper TAB order of enabled buttons
- upDiscPath.setEnabled((activeItems > 0 && activeSelection > 0) ||
- (removedItems > 0 && removedSelection > 0));
- downDiscPath.setEnabled((activeItems > 0 && activeSelection >= 0 && activeSelection < activeItems-1) ||
- (removedItems > 0 && removedSelection >= 0 && removedSelection < removedItems-1));
- removeDiscPath.setEnabled(activeItems > 0 && activeSelection >= 0);
- restoreDiscPath.setEnabled(removedItems > 0 && removedSelection >= 0);
- deleteDiscPath.setEnabled((activeItems > 0 && activeSelection >= 0) ||
- (removedItems > 0 && removedSelection >= 0));
- deleteAllDiscPaths.setEnabled(activeItems > 0 || removedItems > 0);
- }
-
- /**
- * Get the defualt widget height for the supplied control.
- * @return int
- * @param control - the control being queried about fonts
- * @param lines - the number of lines to be shown on the table.
- */
- private static int getDefaultFontHeight(Control control, int lines) {
- FontData[] viewerFontData = control.getFont().getFontData();
- int fontHeight = 10;
-
- //If we have no font data use our guess
- if (viewerFontData.length > 0)
- fontHeight = viewerFontData[0].getHeight();
- return lines * fontHeight;
- }
-
- /**
- * @return
- */
- public String[] getManagedIncludes() {
- if (returnPaths == null) {
- return new String[0];
- }
- return (String[]) returnPaths.toArray(new String[returnPaths.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
- */
- protected void buttonPressed(int buttonId) {
- if (IDialogConstants.OK_ID == buttonId) {
- // Store discovered part
- discoveredPaths = workingDiscoveredPaths;
- // Return sum of user and active discovered paths
- returnPaths = new ArrayList(discActiveList.getItemCount());
- returnPaths.addAll(new ArrayList(Arrays.asList(discActiveList.getItems())));
-
- fDirty = fWorkingDirty;
- }
- else if (IDialogConstants.CANCEL_ID == buttonId) {
- deletedDiscoveredPaths = null;
- workingDiscoveredPaths = null;
- setDirty(false);
- }
- super.buttonPressed(buttonId);
- }
-
- private void setDirty(boolean dirty) {
- fWorkingDirty = dirty;
- }
-
- /**
- * Called by BuildPathInfoBlock.performApply
- * @param info
- * @return boolean - true if changed
- */
- public boolean saveTo(IDiscoveredPathInfo info) {
- if (fDirty || (fProject == null && fContainer.getProject() != null)) {// New Standard Make project wizard
- info.setIncludeMap(discoveredPaths);
- // remove deleted paths from discovered SC
- if (deletedDiscoveredPaths != null) {
- for (Iterator i = deletedDiscoveredPaths.iterator(); i.hasNext(); ) {
- ScannerInfoCollector.getInstance().deletePath(fProject, (String) i.next());
- }
- deletedDiscoveredPaths = null;
- }
- }
- setDirty(false);
- boolean rc = fDirty;
- fDirty = false;
- return rc;
- }
-
- /**
- * Called by BuildPathInfoBlock.performDefaults
- */
- public void restore() {
- if (fProject != null) {
- // remove discovered paths
- ScannerInfoCollector.getInstance().deleteAllPaths(fProject);
- }
- discoveredPaths = new LinkedHashMap();
- deletedDiscoveredPaths = null;
- fDirty = true;
- }
-}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/ScannerConfigOptionsDialog.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/ScannerConfigOptionsDialog.java
deleted file mode 100644
index 70c6060a410..00000000000
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/ScannerConfigOptionsDialog.java
+++ /dev/null
@@ -1,576 +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.make.ui.dialogs;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigBuilder;
-import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
-import org.eclipse.cdt.make.internal.ui.MessageLine;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-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.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.swt.widgets.Text;
-
-/**
- * A dialog to set scanner config discovery options
- *
- * @author vhirsl
- */
-public class ScannerConfigOptionsDialog extends Dialog {
- private static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
- private static final String DIALOG_TITLE = PREFIX + ".title"; //$NON-NLS-1$
- private static final String SI_BUILD_PARSER_GROUP = PREFIX + ".siBuilder.parser.group_label"; //$NON-NLS-1$
- private static final String ENABLE_SI_BUILD_PARSER = PREFIX + ".siBuilder.parser.enable.label"; //$NON-NLS-1$
- private static final String SI_BUILD_PARSER_LABEL = PREFIX + ".siBuilder.parser.label"; //$NON-NLS-1$
- private static final String SI_PROVIDER_CMD_GROUP = PREFIX + ".siProvider.cmd.group_label"; //$NON-NLS-1$
- private static final String ENABLE_SI_PROVIDER_COMMAND = PREFIX + ".siProvider.cmd.enable.label"; //$NON-NLS-1$
- private static final String SI_PROVIDER_CMD_USE_DEFAULT = PREFIX + ".siProvider.cmd.use_default"; //$NON-NLS-1$
- private static final String SI_PROVIDER_CMD_LABEL = PREFIX + ".siProvider.cmd.label"; //$NON-NLS-1$
- private static final String SI_PROVIDER_PARSER_LABEL = PREFIX + ".siProvider.parser.label"; //$NON-NLS-1$
- private static final String SI_PROVIDER_CMD_ERROR_MESSAGE = PREFIX + ".siProvider.cmd.error_message"; //$NON-NLS-1$
-
- private MessageLine fStatusLine;
- private Button defESIProviderCommandButton;
- private Text esiProviderCommand;
- private Button enableBuilderParserButton;
- private Combo makeBuilderSIParserComboBox;
- private Button enableProviderCommandButton;
- private Combo esiProviderParserComboBox;
-
- private ICOptionContainer fContainer;
- private Preferences fPrefs;
- private IScannerConfigBuilderInfo fBuildInfo;
- private boolean fInitialized;
- private Map builderParsers = new HashMap();
- private String initialBuilderParserId = null;
- private Map providerParsers = new HashMap();
- private String initialProviderParserId = null;
-
- /**
- * Local store for Scanner Config discovery setting
- *
- * @author vhirsl
- */
- protected class LocalStore implements IScannerConfigBuilderInfo {
- private boolean fAutoDiscoveryEnabled;
- private boolean fMakeBuilderConsoleParserEnabled;
- private String fMakeBuilderConsoleParserId;
- private boolean fESIProviderCommandEnabled;
- private boolean fDefaultESIProviderCmd;
- private IPath fESIProviderCommand;
- private String fESIProviderArguments;
- private String fESIProviderConsoleParserId;
- private boolean fSIParserGenerationEnabled;
-
- public LocalStore(IScannerConfigBuilderInfo info) {
- try {
- setAutoDiscoveryEnabled(info.isAutoDiscoveryEnabled());
- setMakeBuilderConsoleParserEnabled(info.isMakeBuilderConsoleParserEnabled());
- setMakeBuilderConsoleParserId(info.getMakeBuilderConsoleParserId());
- setESIProviderCommandEnabled(info.isESIProviderCommandEnabled());
- setUseDefaultESIProviderCmd(info.isDefaultESIProviderCmd());
- setESIProviderCommand(info.getESIProviderCommand());
- setESIProviderArguments(info.getESIProviderArguments());
- setESIProviderConsoleParserId(info.getESIProviderConsoleParserId());
- setSIProblemGenerationEnabled(info.isSIProblemGenerationEnabled());
- } catch (CoreException e) {
- }
- }
-
- public boolean isAutoDiscoveryEnabled() {
- return fAutoDiscoveryEnabled;
- }
- public void setAutoDiscoveryEnabled(boolean enabled) throws CoreException {
- fAutoDiscoveryEnabled = enabled;
- }
-
- public boolean isMakeBuilderConsoleParserEnabled() {
- return fMakeBuilderConsoleParserEnabled;
- }
- public void setMakeBuilderConsoleParserEnabled(boolean enabled) throws CoreException {
- fMakeBuilderConsoleParserEnabled = enabled;
- }
-
- public String getMakeBuilderConsoleParserId() {
- return fMakeBuilderConsoleParserId;
- }
- public void setMakeBuilderConsoleParserId(String parserId) throws CoreException {
- fMakeBuilderConsoleParserId = new String(parserId);
-
- }
-
- public boolean isESIProviderCommandEnabled() {
- return fESIProviderCommandEnabled;
- }
- public void setESIProviderCommandEnabled(boolean enabled) throws CoreException {
- fESIProviderCommandEnabled = enabled;
- }
-
- public boolean isDefaultESIProviderCmd() {
- return fDefaultESIProviderCmd;
- }
- public void setUseDefaultESIProviderCmd(boolean on) throws CoreException {
- fDefaultESIProviderCmd = on;
- }
-
- public IPath getESIProviderCommand() {
- return fESIProviderCommand;
- }
- public void setESIProviderCommand(IPath command) throws CoreException {
- fESIProviderCommand = new Path(command.toString());
- }
-
- public String getESIProviderArguments() {
- return fESIProviderArguments;
- }
- public void setESIProviderArguments(String args) throws CoreException {
- fESIProviderArguments = new String(args);
- }
-
- public String getESIProviderConsoleParserId() {
- return fESIProviderConsoleParserId;
- }
- public void setESIProviderConsoleParserId(String parserId) throws CoreException {
- fESIProviderConsoleParserId = new String(parserId);
- }
-
- public boolean isSIProblemGenerationEnabled() {
- return fSIParserGenerationEnabled;
- }
- public void setSIProblemGenerationEnabled(boolean enabled) throws CoreException {
- fSIParserGenerationEnabled = enabled;
- }
- }
-
- /**
- * A temporary page to retrieve SC options from preferences
- * Not to be shown
- *
- * @param container
- */
- ScannerConfigOptionsDialog(ICOptionContainer container) {
- super(null);
- fInitialized = false;
- fContainer = container;
- fPrefs = fContainer.getPreferences();
- IScannerConfigBuilderInfo fInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, false);
- // Create local store
- fBuildInfo = new LocalStore(fInfo);
- }
- /**
- * @param parentShell
- * @param container
- */
- ScannerConfigOptionsDialog(Shell parentShell, ICOptionContainer container) {
- super(parentShell);
- fInitialized = true;
- fContainer = container;
- IProject project = fContainer.getProject();
- fPrefs = fContainer.getPreferences();
-
- IScannerConfigBuilderInfo fInfo;
- if (project != null) {
- try {
- fInfo = MakeCorePlugin.createScannerConfigBuildInfo(project, ScannerConfigBuilder.BUILDER_ID);
- }
- catch (CoreException e) {
- fInitialized = false;
- fInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, true);
- }
- }
- else {
- fInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, false);
- }
- retrieveSIConsoleParsers();
- initialBuilderParserId = fInfo.getMakeBuilderConsoleParserId(); //$NON-NLS-1$
- initialProviderParserId = fInfo.getESIProviderConsoleParserId(); //$NON-NLS-1$
-
- // Create local store
- fBuildInfo = new LocalStore(fInfo);
- }
-
- /**
- * Fills console parser maps
- */
- private void retrieveSIConsoleParsers() {
- IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(MakeCorePlugin.SI_CONSOLE_PARSER_SIMPLE_ID);
- if (ep != null) {
- IExtension[] extensions = ep.getExtensions();
- for (int i = 0; i < extensions.length; ++i) {
- String parserId = extensions[i].getUniqueIdentifier();
- String label = extensions[i].getLabel();
- IConfigurationElement[] elements = extensions[i].getConfigurationElements();
- String commandId = elements[0].getAttribute("commandId"); //$NON-NLS-1$
- if (commandId.equals("makeBuilder") || commandId.equals("all")) { //$NON-NLS-1$//$NON-NLS-2$
- builderParsers.put(label, parserId);
- }
- if (commandId.equals("externalScannerInfoProvider") || commandId.equals("all")) { //$NON-NLS-1$//$NON-NLS-2$
- providerParsers.put(label, parserId);
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
- */
- protected void configureShell(Shell newShell) {
- newShell.setText(getTitle(DIALOG_TITLE));
- super.configureShell(newShell);
- }
-
- /**
- * @return MakeUIPlugin resource string
- */
- private String getTitle(String title) {
- return MakeUIPlugin.getResourceString(title);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- initializeDialogUnits(composite);
-
- // create message line
- fStatusLine = new MessageLine(composite);
- fStatusLine.setAlignment(SWT.LEFT);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-// gd.widthHint = convertWidthInCharsToPixels(50);
- fStatusLine.setLayoutData(gd);
- fStatusLine.setMessage(getTitle(DIALOG_TITLE));
-
- createBuildOutputParserControls(composite);
- createAfterBuildCmdControls(composite);
- // enable controls depending on the state of auto discovery
- enableAllControls();
-
- return composite;
- }
-
- private void createBuildOutputParserControls(Composite parent) {
-// ControlFactory.insertSpace(parent, 1, 10);
- Group bopGroup = ControlFactory.createGroup(parent,
- MakeUIPlugin.getResourceString(SI_BUILD_PARSER_GROUP), 2);
- ((GridLayout)bopGroup.getLayout()).marginHeight = 5;
- ((GridLayout)bopGroup.getLayout()).marginWidth = 5;
- ((GridData)bopGroup.getLayoutData()).verticalAlignment = GridData.FILL;
-
- enableBuilderParserButton = ControlFactory.createCheckBox(bopGroup,
- MakeUIPlugin.getResourceString(ENABLE_SI_BUILD_PARSER));
- ((GridData)enableBuilderParserButton.getLayoutData()).horizontalSpan = 2;
- boolean enabledBuilderParser = fBuildInfo.isMakeBuilderConsoleParserEnabled();
- enableBuilderParserButton.setSelection(enabledBuilderParser);
- enableBuilderParserButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- makeBuilderSIParserComboBox.setEnabled(isBuilderParserEnabled());
- }
- });
-
- Label label = ControlFactory.createLabel(bopGroup,
- MakeUIPlugin.getResourceString(SI_BUILD_PARSER_LABEL));
- ((GridData)label.getLayoutData()).grabExcessHorizontalSpace = false;
-
- makeBuilderSIParserComboBox = new Combo(bopGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
-
- // fill the combobox and set the initial value
- Iterator items = builderParsers.keySet().iterator();
- while (items.hasNext()) {
- String parser = (String) items.next();
- makeBuilderSIParserComboBox.add(parser);
- if (initialBuilderParserId.equals(builderParsers.get(parser))) {
- makeBuilderSIParserComboBox.setText(parser);
- }
- }
- makeBuilderSIParserComboBox.setEnabled(enabledBuilderParser);
- }
-
- private void createAfterBuildCmdControls(Composite parent) {
- Group abcGroup = ControlFactory.createGroup(parent,
- MakeUIPlugin.getResourceString(SI_PROVIDER_CMD_GROUP), 2);
- ((GridData)abcGroup.getLayoutData()).horizontalSpan = 2;
-
- enableProviderCommandButton = ControlFactory.createCheckBox(abcGroup,
- MakeUIPlugin.getResourceString(ENABLE_SI_PROVIDER_COMMAND));
- ((GridData)enableProviderCommandButton.getLayoutData()).horizontalSpan = 2;
- ((GridData)enableProviderCommandButton.getLayoutData()).horizontalAlignment = GridData.FILL_HORIZONTAL;
- boolean enabledProviderCommand = fBuildInfo.isESIProviderCommandEnabled();
- enableProviderCommandButton.setSelection(enabledProviderCommand);
- enableProviderCommandButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- defESIProviderCommandButton.setEnabled(isProviderCommandEnabled());
- esiProviderCommand.setEnabled(isProviderCommandEnabled() && !useDefaultESIProviderCmd());
- esiProviderParserComboBox.setEnabled(isProviderCommandEnabled());
- }
- });
-
- createESIProviderCmdControls(abcGroup);
-
- Label label = ControlFactory.createLabel(abcGroup,
- MakeUIPlugin.getResourceString(SI_PROVIDER_PARSER_LABEL));
- ((GridData)label.getLayoutData()).grabExcessHorizontalSpace = false;
-
- esiProviderParserComboBox = new Combo(abcGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
-
- // fill the combobox and set the initial value
- Iterator items = providerParsers.keySet().iterator();
- while (items.hasNext()) {
- String parser = (String) items.next();
- esiProviderParserComboBox.add(parser);
- if (initialProviderParserId.equals(providerParsers.get(parser))) {
- esiProviderParserComboBox.setText(parser);
- }
- }
- defESIProviderCommandButton.setEnabled(enabledProviderCommand);
- esiProviderCommand.setEnabled(enabledProviderCommand && !useDefaultESIProviderCmd());
- esiProviderParserComboBox.setEnabled(enabledProviderCommand);
- }
-
- private void createESIProviderCmdControls(Composite parent) {
- defESIProviderCommandButton = ControlFactory.createCheckBox(parent,
- MakeUIPlugin.getResourceString(SI_PROVIDER_CMD_USE_DEFAULT));
- defESIProviderCommandButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- esiProviderCommand.setEnabled(!useDefaultESIProviderCmd());
- }
- });
- ((GridData) (defESIProviderCommandButton.getLayoutData())).horizontalAlignment = GridData.FILL_HORIZONTAL;
- ((GridData) (defESIProviderCommandButton.getLayoutData())).horizontalSpan = 2;
- Label label = ControlFactory.createLabel(parent,
- MakeUIPlugin.getResourceString(SI_PROVIDER_CMD_LABEL));
- ((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING;
- ((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false;
- esiProviderCommand = ControlFactory.createTextField(parent, SWT.SINGLE | SWT.BORDER);
- ((GridData) (esiProviderCommand.getLayoutData())).horizontalAlignment = GridData.FILL;
- ((GridData) (esiProviderCommand.getLayoutData())).grabExcessHorizontalSpace = true;
- IPath sCommand = fBuildInfo.getESIProviderCommand();
- if (sCommand != null) {
- StringBuffer cmd = new StringBuffer(sCommand.toOSString());
- String args = fBuildInfo.getESIProviderArguments();
- if (args != null && args.length() > 0) {
- cmd.append(' ');
- cmd.append(args);
- }
- esiProviderCommand.setText(cmd.toString());
- }
- if (fBuildInfo.isDefaultESIProviderCmd()) {
- esiProviderCommand.setEnabled(false);
- }
- esiProviderCommand.addListener(SWT.Modify, new Listener() {
- public void handleEvent(Event e) {
- handleProviderCommandModify();
- }
- });
- defESIProviderCommandButton.setSelection(fBuildInfo.isDefaultESIProviderCmd());
- }
-
- /**
- *
- */
- protected void handleProviderCommandModify() {
- String newCommand = esiProviderCommand.getText().trim();
- if (newCommand.length() == 0) {
- fStatusLine.setErrorMessage(getTitle(SI_PROVIDER_CMD_ERROR_MESSAGE));
- getButton(IDialogConstants.OK_ID).setEnabled(false);
- }
- else {
- fStatusLine.setErrorMessage(null);
- getButton(IDialogConstants.OK_ID).setEnabled(true);
- }
- }
-
- /**
- * @param enable
- */
- private void enableAllControls() {
- enableBuilderParserButton.setEnabled(true);
- makeBuilderSIParserComboBox.setEnabled(isBuilderParserEnabled());
- enableProviderCommandButton.setEnabled(true);
- defESIProviderCommandButton.setEnabled(isProviderCommandEnabled());
- esiProviderCommand.setEnabled(isProviderCommandEnabled() && !useDefaultESIProviderCmd());
- esiProviderParserComboBox.setEnabled(isProviderCommandEnabled());
- }
-
- private boolean useDefaultESIProviderCmd() {
- return defESIProviderCommandButton.getSelection();
- }
-
- private String getSIProviderCommandLine() {
- return esiProviderCommand.getText().trim();
- }
-
- private boolean isBuilderParserEnabled() {
- return enableBuilderParserButton.getSelection();
- }
-
- private boolean isProviderCommandEnabled() {
- return enableProviderCommandButton.getSelection();
- }
-
- /**
- * Retrieves the state of scanner config discovery
- *
- * @return boolean
- */
- public boolean isScannerConfigDiscoveryEnabled() {
- return fBuildInfo.isAutoDiscoveryEnabled();
- }
-
- /**
- * Enables or disables the scanner config discovery
- *
- * @param enabled (boolean)
- */
- public void setScannerConfigDiscoveryEnabled(boolean enabled) {
- try {
- fBuildInfo.setAutoDiscoveryEnabled(enabled);
- }
- catch (CoreException e) {
- }
- }
-
- /**
- * Called by BuildPathInfoBlock.performApply
- *
- * @param monitor
- * @throws CoreException
- */
- public void performApply(IProgressMonitor monitor) throws CoreException {
- IProject project = fContainer.getProject();
- IScannerConfigBuilderInfo buildInfo;
- if (project != null) {
- buildInfo = MakeCorePlugin.createScannerConfigBuildInfo(project, ScannerConfigBuilder.BUILDER_ID);
- }
- else {
- buildInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, false);
- }
-
- buildInfo.setAutoDiscoveryEnabled(fBuildInfo.isAutoDiscoveryEnabled());
- if (fBuildInfo.isAutoDiscoveryEnabled()) {
- buildInfo.setMakeBuilderConsoleParserEnabled(fBuildInfo.isMakeBuilderConsoleParserEnabled());
- if (fBuildInfo.isMakeBuilderConsoleParserEnabled()) {
- buildInfo.setMakeBuilderConsoleParserId(fBuildInfo.getMakeBuilderConsoleParserId());
- }
- buildInfo.setESIProviderCommandEnabled(fBuildInfo.isESIProviderCommandEnabled());
- if (fBuildInfo.isESIProviderCommandEnabled()) {
- buildInfo.setUseDefaultESIProviderCmd(fBuildInfo.isDefaultESIProviderCmd());
- if (!fBuildInfo.isDefaultESIProviderCmd()) {
- buildInfo.setESIProviderCommand(fBuildInfo.getESIProviderCommand());
- buildInfo.setESIProviderArguments(fBuildInfo.getESIProviderArguments());
- }
- buildInfo.setESIProviderConsoleParserId(fBuildInfo.getESIProviderConsoleParserId());
- }
- }
- }
-
- /**
- * @param buildInfo
- * @throws CoreException
- */
- private void storeSIProviderCommandLine(IScannerConfigBuilderInfo buildInfo) throws CoreException {
- String esiProviderLine = getSIProviderCommandLine();
- int start = 0;
- int end = -1;
- if (esiProviderLine.startsWith("\"")) { //$NON-NLS-1$
- start = 1;
- end = esiProviderLine.indexOf('"', 1);
- }
- else {
- end = esiProviderLine.indexOf(' ');
- }
- IPath path;
- if (end == -1) {
- path = new Path(esiProviderLine);
- } else {
- path = new Path(esiProviderLine.substring(start, end));
- }
- buildInfo.setESIProviderCommand(path);
- String args = ""; //$NON-NLS-1$
- if (end != -1) {
- args = esiProviderLine.substring(end + 1);
- }
- buildInfo.setESIProviderArguments(args);
- }
-
- /**
- * Called by BuildPathInfoBlock.performDefaults
- */
- public void performDefaults() {
- IScannerConfigBuilderInfo buildInfo;
- // Populate with the default values
- if (fContainer.getProject() != null) {
- // get the preferences
- buildInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, false);
- }
- else {
- // get the defaults
- buildInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, true);
- }
-
- fBuildInfo = new LocalStore(buildInfo);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
- protected void okPressed() {
- // Store UI values to the LocalStore
- try {
- fBuildInfo.setAutoDiscoveryEnabled(isScannerConfigDiscoveryEnabled());
- fBuildInfo.setMakeBuilderConsoleParserEnabled(isBuilderParserEnabled());
- fBuildInfo.setMakeBuilderConsoleParserId((String)builderParsers.get(makeBuilderSIParserComboBox.getText()));
- fBuildInfo.setESIProviderCommandEnabled(isProviderCommandEnabled());
- fBuildInfo.setUseDefaultESIProviderCmd(useDefaultESIProviderCmd());
- storeSIProviderCommandLine(fBuildInfo);
- fBuildInfo.setESIProviderConsoleParserId((String)providerParsers.get(esiProviderParserComboBox.getText()));
- } catch (CoreException e) {
- }
- super.okPressed();
- }
-
- /**
- * @return true if successfully initialized, false if not
- */
- public boolean isInitialized() {
- return fInitialized;
- }
-} \ No newline at end of file

Back to the top