diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java index cc899afee5f..a32865faf95 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java @@ -63,6 +63,8 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements .getSelection(); if (s.getFirstElement() instanceof IProblem) setSelectedProblem((IProblem) s.getFirstElement()); + else + setSelectedProblem(null); } } } @@ -85,14 +87,26 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements CheckedTreeEditor checkedTreeEditor = new ProblemsTreeEditor( getFieldEditorParent(), profile); addField(checkedTreeEditor); - final TabFolder tabFolder = new TabFolder(getFieldEditorParent(), - SWT.TOP); + checkedTreeEditor.getTreeViewer().addSelectionChangedListener( + problemSelectionListener); + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.cdt.codan.internal.ui.preferences.FieldEditorOverlayPage# + * createContents(org.eclipse.swt.widgets.Composite) + */ + @Override + protected Control createContents(Composite parent) { + Composite comp = (Composite) super.createContents(parent); + final TabFolder tabFolder = new TabFolder(comp, SWT.TOP); tabFolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // createMainTab(tabFolder); createParamtersTab(tabFolder); createScopeTab(tabFolder); - checkedTreeEditor.getTreeViewer().addSelectionChangedListener( - problemSelectionListener); + return comp; } /** @@ -108,11 +122,14 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements Control control = children[i]; control.dispose(); } - ParametersComposite comp = new ParametersComposite(parametersTab, - problem); - comp.setLayoutData(new GridData(GridData.FILL_BOTH)); - parametersTab.pack(true); - parametersTab.layout(true); + if (problem != null) { + ParametersComposite comp = new ParametersComposite(parametersTab, + problem); + comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + parametersTab.pack(true); + getFieldEditorParent().layout(true); + getFieldEditorParent().redraw(); + } } /** @@ -164,12 +181,14 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements * */ private void saveProblemEdits() { - if (selectedProblem==null) return; + if (selectedProblem == null) + return; Control[] children = parametersTab.getChildren(); for (int i = 0; i < children.length; i++) { Control control = children[i]; if (control instanceof ParametersComposite) { - ((ParametersComposite) control).save((IProblemWorkingCopy) selectedProblem); // XXX + ((ParametersComposite) control) + .save((IProblemWorkingCopy) selectedProblem); // XXX } } } diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ParametersComposite.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ParametersComposite.java index f0b4e60914e..eaf4687a0b7 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ParametersComposite.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ParametersComposite.java @@ -20,6 +20,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; /** * @author Alena @@ -54,6 +55,8 @@ public class ParametersComposite extends Composite { */ private void createFieldEditorsForParameters( IProblemParameterInfo info) { + if (info == null) + return; switch (info.getType()) { case TYPE_STRING: StringFieldEditor fe = new StringFieldEditor(info.getKey(), @@ -67,10 +70,15 @@ public class ParametersComposite extends Composite { } }; IProblemParameterInfo info = problem.getParameterInfo(); - initPrefStore(info); - page.setPreferenceStore(pref); - page.createControl(parent); - page.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); + if (info == null) { + Label label = new Label(this, 0); + label.setText("No Parameters"); + } else { + initPrefStore(info); + page.setPreferenceStore(pref); + page.createControl(parent); + page.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); + } } public void save(IProblemWorkingCopy problemwc) { @@ -85,6 +93,8 @@ public class ParametersComposite extends Composite { */ private void savePrefStore(IProblemParameterInfo info, IProblemWorkingCopy problemwc) { + if (info == null) + return; String key = info.getKey(); Object parameter = problem.getParameter(key); if (parameter instanceof String) { @@ -98,6 +108,8 @@ public class ParametersComposite extends Composite { * @param info */ private void initPrefStore(IProblemParameterInfo info) { + if (info == null) + return; String key = info.getKey(); Object parameter = problem.getParameter(key); if (parameter instanceof String) {