summaryrefslogtreecommitdiffstats
path: root/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FieldEditorOverlayPage.java
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FieldEditorOverlayPage.java')
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FieldEditorOverlayPage.java34
1 files changed, 21 insertions, 13 deletions
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FieldEditorOverlayPage.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FieldEditorOverlayPage.java
index e617a75..714d841 100644
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FieldEditorOverlayPage.java
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FieldEditorOverlayPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003 Berthold Daum.
+ * Copyright (c) 2003, 2010 Berthold Daum.
* 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
@@ -16,6 +16,7 @@ import java.util.List;
import org.eclipse.cdt.codan.core.CodanCorePlugin;
import org.eclipse.cdt.codan.core.PreferenceConstants;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.IAdaptable;
@@ -121,6 +122,10 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage
* @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
*/
public IAdaptable getElement() {
+ if (element == null)
+ return element;
+ if (!(element instanceof IProject))
+ return (IAdaptable) element.getAdapter(IProject.class);
return element;
}
@@ -157,12 +162,15 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage
// Cache the page id
pageId = getPageId();
// Create an overlay preference store and fill it with properties
- ProjectScope ps = new ProjectScope((IProject) getElement());
- ScopedPreferenceStore scoped = new ScopedPreferenceStore(ps,
- CodanCorePlugin.PLUGIN_ID);
- scoped.setSearchContexts(new IScopeContext[] { ps,
- new InstanceScope() });
- overlayStore = scoped;
+ IAdaptable e = getElement();
+ if (e != null) {
+ ProjectScope ps = new ProjectScope((IProject) e);
+ ScopedPreferenceStore scoped = new ScopedPreferenceStore(ps,
+ CodanCorePlugin.PLUGIN_ID);
+ scoped.setSearchContexts(new IScopeContext[] { ps,
+ new InstanceScope() });
+ overlayStore = scoped;
+ }
// Set overlay store as current preference store
}
super.createControl(parent);
@@ -200,13 +208,12 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage
Composite radioGroup = new Composite(comp, SWT.NONE);
radioGroup.setLayout(new GridLayout());
radioGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- useWorkspaceSettingsButton = createRadioButton(radioGroup, Messages
- .getString("OverlayPage.Use_Workspace_Settings")); //$NON-NLS-1$
- useProjectSettingsButton = createRadioButton(radioGroup, Messages
- .getString("OverlayPage.Use_Project_Settings")); //$NON-NLS-1$
+ useWorkspaceSettingsButton = createRadioButton(radioGroup,
+ CodanUIMessages.OverlayPage_Use_Workspace_Settings);
+ useProjectSettingsButton = createRadioButton(radioGroup,
+ CodanUIMessages.OverlayPage_Use_Project_Settings);
configureButton = new Button(comp, SWT.PUSH);
- configureButton.setText(Messages
- .getString("OverlayPage.Configure_Workspace_Settings")); //$NON-NLS-1$
+ configureButton.setText(CodanUIMessages.OverlayPage_Use_Workspace_Settings);
configureButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
configureWorkspaceSettings();
@@ -322,6 +329,7 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage
/**
* Creates a new preferences page and opens it
*/
+ @SuppressWarnings("cast")
protected void configureWorkspaceSettings() {
try {
// create a new instance of the current class