Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Hirsl2005-03-01 19:41:19 +0000
committerVladimir Hirsl2005-03-01 19:41:19 +0000
commit0944b253a3d86e065b268a34485c43f165ce599c (patch)
tree651db3120d01d7fc2676cbea921843263a329e31 /build/org.eclipse.cdt.make.ui
parent877ceeab4e2580a7093b700bfac0c68a571b14d9 (diff)
downloadorg.eclipse.cdt-0944b253a3d86e065b268a34485c43f165ce599c.tar.gz
org.eclipse.cdt-0944b253a3d86e065b268a34485c43f165ce599c.tar.xz
org.eclipse.cdt-0944b253a3d86e065b268a34485c43f165ce599c.zip
SCD profiles: integration with CPathEntry framework.
New PerFileDiscoveredPathContainer. Updating CPathEntries on profile change.
Diffstat (limited to 'build/org.eclipse.cdt.make.ui')
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties8
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryOptionsBlock.java90
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryPage.java6
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveryOptionsBlock.java36
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerFileSCDProfilePage.java1
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerProjectSCDProfilePage.java1
6 files changed, 127 insertions, 15 deletions
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 10b5761d98e..5f7b7c7f504 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
@@ -234,6 +234,14 @@ ScannerConfigOptionsDialog.siProvider.browse.runCommandDialog='gcc' command:
ScannerConfigOptionsDialog.siProvider.command.errorMessage=Must enter compiler invocation command
ScannerConfigOptionsDialog.apply.progressMessage=Setting scanner configuration discovery options...
+ScannerConfigOptionsDialog.unsavedchanges.title=Setting C/C++ Make Project Discovery Options
+ScannerConfigOptionsDialog.unsavedchanges.message=The C/C++ Make Project Discovery Options property page contains unsaved modifications. Do you want to save changes so that other discovery related settings can be updated?
+ScannerConfigOptionsDialog.unsavedchanges.button.save=Apply
+ScannerConfigOptionsDialog.unsavedchanges.button.cancel=Cancel
+
+ScannerConfigOptionsDialog.error.title=Error Setting Project Discovery options
+ScannerConfigOptionsDialog.error.message=An error occurred while setting the project 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
index 892a5ff52f7..1c04c481f3b 100644
--- 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
@@ -10,12 +10,15 @@
***********************************************************************/
package org.eclipse.cdt.make.ui.dialogs;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathEntryMessages;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
@@ -26,8 +29,12 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.widgets.Composite;
@@ -37,10 +44,21 @@ import org.eclipse.swt.widgets.Composite;
* @author vhirsl
*/
public abstract class AbstractDiscoveryOptionsBlock extends AbstractCOptionPage {
+ protected static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
+ private static final String UNSAVEDCHANGES_TITLE = PREFIX + ".unsavedchanges.title"; //$NON-NLS-1$
+ private static final String UNSAVEDCHANGES_MESSAGE = PREFIX + ".unsavedchanges.message"; //$NON-NLS-1$
+ private static final String UNSAVEDCHANGES_BSAVE = PREFIX + ".unsavedchanges.button.save"; //$NON-NLS-1$
+ private static final String UNSAVEDCHANGES_BCANCEL = PREFIX + ".unsavedchanges.button.cancel"; //$NON-NLS-1$
+ private static final String ERROR_TITLE = PREFIX + ".error.title"; //$NON-NLS-1$
+ private static final String ERROR_MESSAGE = PREFIX + ".error.message"; //$NON-NLS-1$
+ private static final String PROFILE_PAGE = "profilePage"; //$NON-NLS-1$
+ private static final String PROFILE_ID = "profileId"; //$NON-NLS-1$
+
private Preferences fPrefs;
private IScannerConfigBuilderInfo2 fBuildInfo;
private boolean fInitialized = false;
-
+ private String fPersistedProfileId = null;
+
private Map fProfilePageMap = null;
// Composite parent provided by the block.
@@ -77,6 +95,41 @@ public abstract class AbstractDiscoveryOptionsBlock extends AbstractCOptionPage
protected void setInitialized(boolean initialized) {
fInitialized = initialized;
}
+
+ /**
+ * @return true - OK to continue
+ */
+ public boolean checkDialogForChanges() {
+ boolean rc = true;
+ if (isProfileDifferentThenPersisted()) {
+ String title = MakeUIPlugin.getResourceString(UNSAVEDCHANGES_TITLE);
+ String message = MakeUIPlugin.getResourceString(UNSAVEDCHANGES_MESSAGE);
+ String[] buttonLabels = new String[]{
+ MakeUIPlugin.getResourceString(UNSAVEDCHANGES_BSAVE),
+ MakeUIPlugin.getResourceString(UNSAVEDCHANGES_BCANCEL),
+ };
+ MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION,
+ buttonLabels, 0);
+ int res = dialog.open();
+ if (res == 0) { // OK
+ callPerformApply();
+ rc = true;
+ } else if (res == 1) { // CANCEL
+ rc = false;
+ }
+ }
+ return rc;
+ }
+
+ public boolean isProfileDifferentThenPersisted() {
+ return (fPersistedProfileId != null &&
+ !fPersistedProfileId.equals(getBuildInfo().getSelectedProfileId()));
+ }
+
+ public void updatePersistedProfile() {
+ fPersistedProfileId = getBuildInfo().getSelectedProfileId();
+ }
+
/**
* Create a profile page only on request
*
@@ -128,8 +181,8 @@ public abstract class AbstractDiscoveryOptionsBlock extends AbstractCOptionPage
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$
+ if (infos[i].getName().equals(PROFILE_PAGE)) { //$NON-NLS-1$
+ String id = infos[i].getAttribute(PROFILE_ID); //$NON-NLS-1$
fProfilePageMap.put(id, new DiscoveryProfilePageConfiguration(infos[i]));
}
}
@@ -156,6 +209,9 @@ public abstract class AbstractDiscoveryOptionsBlock extends AbstractCOptionPage
} else {
fBuildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fPrefs, false);
}
+ if (fBuildInfo != null) {
+ fPersistedProfileId = fBuildInfo.getSelectedProfileId();
+ }
}
protected void updateContainer() {
@@ -215,7 +271,7 @@ public abstract class AbstractDiscoveryOptionsBlock extends AbstractCOptionPage
}
/**
- * Notification that the user changed the selection of the Binary Parser.
+ * Notification that the user changed the selection of the SCD profile.
*/
protected void handleDiscoveryProfileChanged() {
if (getCompositeParent() == null) {
@@ -297,5 +353,31 @@ public abstract class AbstractDiscoveryOptionsBlock extends AbstractCOptionPage
}
protected abstract String getCurrentProfileId();
+
+ /**
+ *
+ */
+ public void callPerformApply() {
+ try {
+ new ProgressMonitorDialog(getShell()).run(false, false, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ performApply(monitor);
+ }
+ catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+
+ });
+ } catch (InvocationTargetException e) {
+ String title = CPathEntryMessages.getString(ERROR_TITLE); //$NON-NLS-1$
+ String message = CPathEntryMessages.getString(ERROR_MESSAGE); //$NON-NLS-1$
+ ExceptionHandler.handle(e, getShell(), title, message);
+ } catch (InterruptedException e) {
+ // cancelled
+ }
+ }
+
}
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
index 92a233772c1..6620412b52a 100644
--- 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
@@ -15,15 +15,15 @@ import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.resource.ImageDescriptor;
/**
- * TODO Provide description
+ * Abstract SCD profile page
*
* @author vhirsl
*/
public abstract class AbstractDiscoveryPage extends DialogPage {
protected static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
protected static final String PROFILE_GROUP_LABEL = PREFIX + ".profile.group.label"; //$NON-NLS-1$
-
- protected AbstractDiscoveryOptionsBlock fContainer;
+
+ protected AbstractDiscoveryOptionsBlock fContainer; // parent
/**
* @return Returns the fContainer.
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 f3aa19d07ce..c38e481db2c 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
@@ -22,8 +22,10 @@ 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.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.preferences.TabFolderLayout;
import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
@@ -55,7 +57,6 @@ import org.eclipse.ui.help.WorkbenchHelp;
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$
@@ -73,6 +74,7 @@ public class DiscoveryOptionsBlock extends AbstractDiscoveryOptionsBlock {
private boolean needsSCNature = false;
private boolean fCreatePathContainer = false;
private boolean isValid = true;
+ private boolean persistedProfileChanged = false; // new persisted selected profile different than the old one
/**
*
@@ -227,6 +229,16 @@ public class DiscoveryOptionsBlock extends AbstractDiscoveryOptionsBlock {
* @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
*/
public void setVisible(boolean visible) {
+ if (!visible) {
+ if (!checkDialogForChanges()) {
+ createBuildInfo();
+ restoreFromBuildinfo(getBuildInfo());
+ enableAllControls();
+ handleDiscoveryProfileChanged();
+
+ getCurrentPage().performDefaults();
+ }
+ }
super.setVisible(visible);
enableAllControls();
}
@@ -267,6 +279,10 @@ public class DiscoveryOptionsBlock extends AbstractDiscoveryOptionsBlock {
configureProject(project, monitor);
}
getBuildInfo().save();
+ if (isProfileDifferentThenPersisted()) {
+ changeDiscoveryContainer(project);
+ updatePersistedProfile();
+ }
}
monitor.done();
}
@@ -308,17 +324,21 @@ public class DiscoveryOptionsBlock extends AbstractDiscoveryOptionsBlock {
MakeCorePlugin.getDefault().getDiscoveryManager().removeDiscoveredInfo(project);
}
+ /**
+ * @param project
+ */
+ private void changeDiscoveryContainer(IProject project) {
+ String profileId = getBuildInfo().getSelectedProfileId();
+ ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance().
+ getSCProfileConfiguration(profileId).getProfileScope();
+ MakeCorePlugin.getDefault().getDiscoveryManager().changeDiscoveredContainer(project, profileScope);
+ }
+
private void populateBuildInfo(IScannerConfigBuilderInfo2 buildInfo) {
if (buildInfo != null) {
buildInfo.setAutoDiscoveryEnabled(scEnabledButton.getSelection());
String profileName = profileComboBox.getItem(profileComboBox.getSelectionIndex());
- String oldProfileId = buildInfo.getSelectedProfileId();
buildInfo.setSelectedProfileId(getDiscoveryProfileId(profileName));
- String newProfileId = buildInfo.getSelectedProfileId();
- if (!oldProfileId.equals(newProfileId) && getProject() != null) {
- // invalidate scanner config store and reload
-// MakeCorePlugin.getDefault().getDiscoveryManager().removeDiscoveredInfo(getProject());
- }
buildInfo.setProblemReportingEnabled(scProblemReportingEnabledButton.getSelection());
}
}
@@ -345,7 +365,7 @@ public class DiscoveryOptionsBlock extends AbstractDiscoveryOptionsBlock {
private void restoreFromBuildinfo(IScannerConfigBuilderInfo2 buildInfo) {
if (buildInfo != null) {
scEnabledButton.setSelection(buildInfo.isAutoDiscoveryEnabled());
- String profileId = buildInfo.getSelectedProfileId();
+ 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/GCCPerFileSCDProfilePage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerFileSCDProfilePage.java
index 9b2bc09ceb6..7eec7c3869b 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerFileSCDProfilePage.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerFileSCDProfilePage.java
@@ -216,6 +216,7 @@ public class GCCPerFileSCDProfilePage extends AbstractDiscoveryPage {
}
private void handleBOPLoadFileButtonSelected() {
+ if (!getContainer().checkDialogForChanges()) return;
loadButtonInitialEnabled = false;
bopLoadButton.setEnabled(false);
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
index cd917c05f7e..780e683734e 100644
--- 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
@@ -294,6 +294,7 @@ public class GCCPerProjectSCDProfilePage extends AbstractDiscoveryPage {
}
private void handleBOPLoadFileButtonSelected() {
+ if (!getContainer().checkDialogForChanges()) return;
loadButtonInitialEnabled = false;
bopLoadButton.setEnabled(false);

Back to the top