summaryrefslogtreecommitdiffstats
path: root/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences')
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java45
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Entries15
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Tag1
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CheckedTreeEditor.java5
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java210
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FieldEditorOverlayPage.java34
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FileScopePreferencePage.java312
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/Messages.java47
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/Messages.properties4
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/PreferenceInitializer.java13
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java100
11 files changed, 646 insertions, 140 deletions
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java
index 95f7ff6..4155cce 100644
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java
@@ -1,17 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Alena Laskavaia 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:
+ * Alena Laskavaia - initial API and implementation
+ *******************************************************************************/
package org.eclipse.cdt.codan.internal.ui.preferences;
-import org.eclipse.cdt.codan.core.CodanCorePlugin;
import org.eclipse.cdt.codan.core.PreferenceConstants;
-import org.eclipse.cdt.codan.ui.actions.ToggleNatureAction;
+import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
+import org.eclipse.cdt.codan.internal.ui.actions.ToggleNatureAction;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.IWorkbenchPropertyPage;
-import org.eclipse.ui.preferences.ScopedPreferenceStore;
public class BuildPropertyPage extends FieldEditorPreferencePage implements
IWorkbenchPropertyPage {
@@ -21,8 +29,7 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements
*
*/
public BuildPropertyPage() {
- setPreferenceStore(org.eclipse.cdt.codan.ui.Activator.getDefault()
- .getPreferenceStore());
+ setPreferenceStore(CodanUIActivator.getDefault().getPreferenceStore());
}
/*
@@ -35,7 +42,9 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements
@Override
protected void createFieldEditors() {
addField(new BooleanFieldEditor(PreferenceConstants.P_RUN_ON_BUILD,
- "&Run with Build", getFieldEditorParent()));
+ CodanUIMessages.BuildPropertyPage_RunWithBuild, getFieldEditorParent()));
+ addField(new BooleanFieldEditor(PreferenceConstants.P_RUN_IN_EDITOR,
+ CodanUIMessages.BuildPropertyPage_RunAsYouType, getFieldEditorParent()));
}
@Override
@@ -70,7 +79,9 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements
* @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
*/
public IAdaptable getElement() {
- return element;
+ if (element.getAdapter(IProject.class) != null)
+ return (IProject) element.getAdapter(IProject.class);
+ return null;
}
/*
@@ -82,16 +93,14 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements
*/
public void setElement(IAdaptable element) {
this.element = element;
- ProjectScope ps = new ProjectScope((IProject) getElement());
- ScopedPreferenceStore scoped = new ScopedPreferenceStore(ps,
- CodanCorePlugin.PLUGIN_ID);
- scoped
- .setSearchContexts(new IScopeContext[] { ps,
- new InstanceScope() });
- setPreferenceStore(scoped);
+ if (getElement() != null) {
+ IPreferenceStore scoped = CodanUIActivator.getDefault()
+ .getPreferenceStore(((IProject) getElement()));
+ setPreferenceStore(scoped);
+ }
}
protected String getPageId() {
- return "org.eclipse.cdt.codan.internal.ui.preferences.CodanPreferencePage";
+ return "org.eclipse.cdt.codan.internal.ui.preferences.CodanPreferencePage"; //$NON-NLS-1$
}
}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Entries b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Entries
index 980f899..f152569 100644
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Entries
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Entries
@@ -1,8 +1,7 @@
-/BuildPropertyPage.java/1.4/Sat Aug 22 21:16:50 2009//
-/CheckedTreeEditor.java/1.4/Wed Apr 22 01:26:58 2009//
-/CodanPreferencePage.java/1.4/Sat Aug 22 21:16:50 2009//
-/FieldEditorOverlayPage.java/1.3/Sat Apr 18 04:01:44 2009//
-/Messages.java/1.1/Thu Apr 9 12:47:54 2009//
-/Messages.properties/1.1/Thu Apr 9 12:47:54 2009//
-/PreferenceInitializer.java/1.2/Thu Apr 16 01:46:56 2009//
-/ProblemsTreeEditor.java/1.8/Wed Dec 16 21:48:50 2009//
+/BuildPropertyPage.java/1.10/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
+/CheckedTreeEditor.java/1.7/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
+/CodanPreferencePage.java/1.16/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
+/FieldEditorOverlayPage.java/1.7/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
+/FileScopePreferencePage.java/1.2/Thu Jun 3 17:01:39 2010//TCDT_7_0_0
+/PreferenceInitializer.java/1.6/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
+/ProblemsTreeEditor.java/1.17/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Tag b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CheckedTreeEditor.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CheckedTreeEditor.java
index 7c98ef4..ce55a32 100644
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CheckedTreeEditor.java
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CheckedTreeEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 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
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.codan.internal.ui.preferences;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
@@ -312,7 +313,7 @@ public abstract class CheckedTreeEditor extends FieldEditor implements
if (!emptySelectionAllowed) {
Object[] checkedElements = getTreeViewer().getCheckedElements();
if (checkedElements.length == 0) {
- showErrorMessage("Selection cannot be empty");
+ showErrorMessage(CodanUIMessages.CheckedTreeEditor_SelectionCannotBeEmpty);
return false;
}
}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java
index 35b9a8f..825e8cd 100644
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 Alena Laskavaia
* 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
@@ -10,12 +10,37 @@
*******************************************************************************/
package org.eclipse.cdt.codan.internal.ui.preferences;
+import java.text.MessageFormat;
+
import org.eclipse.cdt.codan.core.CodanCorePlugin;
import org.eclipse.cdt.codan.core.CodanRuntime;
import org.eclipse.cdt.codan.core.model.ICheckersRegistry;
+import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.core.model.IProblemProfile;
+import org.eclipse.cdt.codan.core.param.IProblemPreference;
+import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
+import org.eclipse.cdt.codan.internal.ui.dialogs.CustomizeProblemDialog;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+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.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
@@ -33,16 +58,39 @@ import org.eclipse.ui.preferences.ScopedPreferenceStore;
public class CodanPreferencePage extends FieldEditorOverlayPage implements
IWorkbenchPreferencePage {
private IProblemProfile profile;
+ private ISelectionChangedListener problemSelectionListener;
+ private IProblem selectedProblem;
+ private Group info;
+ private Label infoDesc;
+ private Label infoMessage;
+ private Label infoParams;
+ private Button infoButton;
+ private ProblemsTreeEditor checkedTreeEditor;
public CodanPreferencePage() {
super(GRID);
setPreferenceStore(new ScopedPreferenceStore(new InstanceScope(),
CodanCorePlugin.PLUGIN_ID));
- setDescription("Code Analyzers Preference Page");
+ // setDescription("Code Analysis Preference Page");
+ problemSelectionListener = new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ if (info != null) {
+ if (event.getSelection() instanceof ITreeSelection) {
+ ITreeSelection s = (ITreeSelection) event
+ .getSelection();
+ if (s.getFirstElement() instanceof IProblem)
+ setSelectedProblem((IProblem) s.getFirstElement());
+ else
+ setSelectedProblem(null);
+ }
+ }
+ }
+ };
}
+ @Override
protected String getPageId() {
- return "org.eclipse.cdt.codan.internal.ui.preferences.CodanPreferencePage";
+ return "org.eclipse.cdt.codan.internal.ui.preferences.CodanPreferencePage"; //$NON-NLS-1$
}
/**
@@ -50,13 +98,93 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements
* GUI blocks needed to manipulate various types of preferences. Each field
* editor knows how to save and restore itself.
*/
+ @Override
public void createFieldEditors() {
profile = isPropertyPage() ? getRegistry()
.getResourceProfileWorkingCopy((IResource) getElement())
: getRegistry().getWorkspaceProfile();
- CheckedTreeEditor checkedTreeEditor = new ProblemsTreeEditor(
- getFieldEditorParent(), profile);
+ checkedTreeEditor = new ProblemsTreeEditor(getFieldEditorParent(),
+ profile);
addField(checkedTreeEditor);
+ checkedTreeEditor.getTreeViewer().addSelectionChangedListener(
+ problemSelectionListener);
+ checkedTreeEditor.getTreeViewer().addDoubleClickListener(
+ new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ openCustomizeDialog();
+ }
+ });
+ }
+
+ /*
+ * (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);
+ createInfoControl(comp);
+ return comp;
+ }
+
+ /**
+ * @param comp
+ */
+ private void createInfoControl(Composite comp) {
+ info = new Group(comp, SWT.NONE);
+ info.setLayoutData(new GridData(GridData.FILL_BOTH));
+ info.setLayout(new GridLayout(3, false));
+ info.setText(CodanUIMessages.CodanPreferencePage_Info);
+ GridDataFactory gdLab = GridDataFactory.swtDefaults()
+ .align(SWT.BEGINNING, SWT.BEGINNING).grab(false, false);
+ GridDataFactory gdFact = GridDataFactory.swtDefaults()
+ .align(SWT.BEGINNING, SWT.BEGINNING).grab(true, true);
+ // message
+ Label labelMessage = new Label(info, SWT.NONE);
+ labelMessage.setText(CodanUIMessages.CodanPreferencePage_MessageLabel);
+ labelMessage.setLayoutData(gdLab.create());
+ infoMessage = new Label(info, SWT.WRAP);
+ infoMessage.setLayoutData(gdFact.copy().span(2, 1).create());
+ // description
+ Label labelDesc = new Label(info, SWT.NONE);
+ labelDesc.setText(CodanUIMessages.CodanPreferencePage_Description);
+ labelDesc.setLayoutData(gdLab.create());
+ infoDesc = new Label(info, SWT.WRAP);
+ PixelConverter pixelConverter = new PixelConverter(comp);
+ infoDesc.setLayoutData(gdFact
+ .copy()
+ .span(2, 1)
+ .hint(pixelConverter.convertWidthInCharsToPixels(60),
+ pixelConverter.convertHeightInCharsToPixels(3))
+ .create());
+ // params
+ Label labelParams = new Label(info, SWT.NONE);
+ labelParams.setText(CodanUIMessages.CodanPreferencePage_Parameters);
+ labelParams.setLayoutData(gdLab.create());
+ infoParams = new Label(info, SWT.NONE);
+ infoParams.setLayoutData(gdFact.create());
+ infoButton = new Button(info, SWT.PUSH);
+ infoButton.setLayoutData(GridDataFactory.swtDefaults()
+ .align(SWT.END, SWT.BEGINNING).create());
+ infoButton.setText(CodanUIMessages.CodanPreferencePage_Customize);
+ infoButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ openCustomizeDialog();
+ }
+ });
+ restoreWidgetValues();
+ }
+
+ /**
+ * @param selection
+ */
+ protected void setSelectedProblem(IProblem problem) {
+ this.selectedProblem = problem;
+ updateProblemInfo();
}
/**
@@ -73,11 +201,70 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements
*/
@Override
public boolean performOk() {
- if (isPropertyPage())
- getRegistry().updateProfile((IResource) getElement(), null);
+ saveWidgetValues();
+ // if (isPropertyPage())
+ getRegistry().updateProfile((IResource) getElement(), null);
return super.performOk();
}
+ /**
+ *
+ */
+ private void saveWidgetValues() {
+ CodanUIActivator
+ .getDefault()
+ .getDialogSettings()
+ .put(getWidgetId(),
+ selectedProblem == null ? "" : selectedProblem.getId()); //$NON-NLS-1$
+ }
+
+ private void restoreWidgetValues() {
+ String id = CodanUIActivator.getDefault().getDialogSettings()
+ .get(getWidgetId());
+ if (id != null && id.length() > 0) {
+ checkedTreeEditor.getTreeViewer().setSelection(
+ new StructuredSelection(profile.findProblem(id)), true);
+ } else {
+ setSelectedProblem(null);
+ }
+ }
+
+ /**
+ * @return
+ */
+ protected String getWidgetId() {
+ return getPageId() + ".selection"; //$NON-NLS-1$
+ }
+
+ /**
+ *
+ */
+ private void updateProblemInfo() {
+ if (selectedProblem == null) {
+ infoMessage.setText(""); //$NON-NLS-1$
+ infoDesc.setText(""); //$NON-NLS-1$
+ infoParams.setText(""); //$NON-NLS-1$
+ infoButton.setEnabled(false);
+ } else {
+ IProblemPreference pref = selectedProblem.getPreference();
+ String description = selectedProblem.getDescription();
+ if (description == null)
+ description = CodanUIMessages.CodanPreferencePage_NoInfo;
+ String messagePattern = selectedProblem.getMessagePattern();
+ String message = CodanUIMessages.CodanPreferencePage_NoInfo;
+ if (messagePattern != null) {
+ message = MessageFormat.format(messagePattern, "X", "Y", "Z"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ infoMessage.setText(message);
+ infoDesc.setText(description);
+ infoParams
+ .setText(pref == null ? CodanUIMessages.CodanPreferencePage_NoInfo
+ : CodanUIMessages.CodanPreferencePage_HasPreferences);
+ infoButton.setEnabled(true);
+ }
+ info.layout(true);
+ }
+
/*
* (non-Javadoc)
*
@@ -86,4 +273,13 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements
*/
public void init(IWorkbench workbench) {
}
+
+ /**
+ *
+ */
+ protected void openCustomizeDialog() {
+ CustomizeProblemDialog d = new CustomizeProblemDialog(getShell(),
+ selectedProblem, (IResource) getElement());
+ d.open();
+ }
} \ No newline at end of file
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
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FileScopePreferencePage.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FileScopePreferencePage.java
new file mode 100644
index 0000000..149dee9
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FileScopePreferencePage.java
@@ -0,0 +1,312 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Alena Laskavaia 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:
+ * Alena Laskavaia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.codan.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.cdt.codan.core.param.FileScopeProblemPreference;
+import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
+import org.eclipse.cdt.codan.internal.ui.dialogs.ExclusionInclusionEntryDialog;
+import org.eclipse.cdt.codan.internal.ui.widgets.BasicElementLabels;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+public class FileScopePreferencePage extends PreferencePage {
+ private ListDialogField fInclusionPatternList;
+ private ListDialogField fExclusionPatternList;
+ private FileScopeProblemPreference fCurrElement;
+ private IProject fCurrProject;
+ private IContainer fCurrSourceFolder;
+ private static final int IDX_ADD = 0;
+ private static final int IDX_ADD_MULTIPLE = 1;
+ private static final int IDX_EDIT = 2;
+ private static final int IDX_REMOVE = 4;
+
+ public FileScopePreferencePage(FileScopeProblemPreference entryToEdit) {
+ setTitle(CodanUIMessages.ExclusionInclusionDialog_title);
+ setDescription(CodanUIMessages.ExclusionInclusionDialog_description2);
+ fCurrElement = entryToEdit;
+ fCurrProject = entryToEdit.getProject();
+ IWorkspaceRoot root = fCurrProject != null ? fCurrProject
+ .getWorkspace().getRoot() : ResourcesPlugin.getWorkspace()
+ .getRoot();
+ IResource res = root.findMember(entryToEdit.getPath());
+ if (res instanceof IContainer) {
+ fCurrSourceFolder = (IContainer) res;
+ }
+ if (res == null)
+ fCurrSourceFolder = root;
+ String excLabel = CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_label;
+ ImageDescriptor excDescriptor = null; //JavaPluginImages.DESC_OBJS_EXCLUSION_FILTER_ATTRIB;
+ String[] excButtonLabels = new String[] {
+ CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_add,
+ CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_add_multiple,
+ CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_edit,
+ null,
+ CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_remove };
+ String incLabel = CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_label;
+ ImageDescriptor incDescriptor = null; //JavaPluginImages.DESC_OBJS_INCLUSION_FILTER_ATTRIB;
+ String[] incButtonLabels = new String[] {
+ CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_add,
+ CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_add_multiple,
+ CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_edit,
+ null,
+ CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_remove };
+ fExclusionPatternList = createListContents(entryToEdit,
+ FileScopeProblemPreference.EXCLUSION, excLabel, null,
+ excButtonLabels);
+ fInclusionPatternList = createListContents(entryToEdit,
+ FileScopeProblemPreference.INCLUSION, incLabel, null,
+ incButtonLabels);
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ Composite inner = new Composite(parent, SWT.NONE);
+ inner.setFont(parent.getFont());
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.numColumns = 2;
+ inner.setLayout(layout);
+ inner.setLayoutData(new GridData(GridData.FILL_BOTH));
+ fInclusionPatternList.doFillIntoGrid(inner, 3);
+ LayoutUtil.setHorizontalSpan(
+ fInclusionPatternList.getLabelControl(null), 2);
+ LayoutUtil.setHorizontalGrabbing(fInclusionPatternList
+ .getListControl(null));
+ fExclusionPatternList.doFillIntoGrid(inner, 3);
+ LayoutUtil.setHorizontalSpan(
+ fExclusionPatternList.getLabelControl(null), 2);
+ LayoutUtil.setHorizontalGrabbing(fExclusionPatternList
+ .getListControl(null));
+ setControl(inner);
+ Dialog.applyDialogFont(inner);
+ return inner;
+ }
+
+ private static class ExclusionInclusionLabelProvider extends LabelProvider {
+ private Image fElementImage;
+
+ public ExclusionInclusionLabelProvider(String descriptorPath) {
+ if (descriptorPath != null) {
+ ImageDescriptor d = CodanUIActivator
+ .getImageDescriptor(descriptorPath);
+ }
+ fElementImage = null; // XXX
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ return fElementImage;
+ }
+
+ @Override
+ public String getText(Object element) {
+ return BasicElementLabels.getFilePattern((String) element);
+ }
+ }
+
+ private ListDialogField createListContents(
+ FileScopeProblemPreference entryToEdit, String key, String label,
+ String descriptor, String[] buttonLabels) {
+ ExclusionPatternAdapter adapter = new ExclusionPatternAdapter();
+ ListDialogField patternList = new ListDialogField(adapter,
+ buttonLabels, new ExclusionInclusionLabelProvider(descriptor));
+ patternList.setDialogFieldListener(adapter);
+ patternList.setLabelText(label);
+ patternList.enableButton(IDX_EDIT, false);
+ IPath[] pattern = entryToEdit.getAttribute(key);
+ ArrayList elements = new ArrayList(pattern.length);
+ for (int i = 0; i < pattern.length; i++) {
+ String patternName = pattern[i].toString();
+ if (patternName.length() > 0)
+ elements.add(patternName);
+ }
+ patternList.setElements(elements);
+ patternList.selectFirstElement();
+ patternList.enableButton(IDX_ADD_MULTIPLE, fCurrSourceFolder != null);
+ patternList.setViewerComparator(new ViewerComparator());
+ return patternList;
+ }
+
+ protected void doCustomButtonPressed(ListDialogField field, int index) {
+ if (index == IDX_ADD) {
+ addEntry(field);
+ } else if (index == IDX_EDIT) {
+ editEntry(field);
+ } else if (index == IDX_ADD_MULTIPLE) {
+ addMultipleEntries(field);
+ } else if (index == IDX_REMOVE) {
+ field.removeElements(field.getSelectedElements());
+ }
+ updateStatus();
+ }
+
+ private void updateStatus() {
+ fCurrElement.setAttribute(FileScopeProblemPreference.INCLUSION,
+ getInclusionPattern());
+ fCurrElement.setAttribute(FileScopeProblemPreference.EXCLUSION,
+ getExclusionPattern());
+ }
+
+ protected void doDoubleClicked(ListDialogField field) {
+ editEntry(field);
+ updateStatus();
+ }
+
+ protected void doSelectionChanged(ListDialogField field) {
+ List selected = field.getSelectedElements();
+ field.enableButton(IDX_EDIT, canEdit(selected));
+ }
+
+ private boolean canEdit(List selected) {
+ return selected.size() == 1;
+ }
+
+ private void editEntry(ListDialogField field) {
+ List selElements = field.getSelectedElements();
+ if (selElements.size() != 1) {
+ return;
+ }
+ List existing = field.getElements();
+ String entry = (String) selElements.get(0);
+ ExclusionInclusionEntryDialog dialog = new ExclusionInclusionEntryDialog(
+ getShell(), isExclusion(field), entry, existing, fCurrElement);
+ if (dialog.open() == Window.OK) {
+ field.replaceElement(entry, dialog.getExclusionPattern());
+ }
+ }
+
+ private boolean isExclusion(ListDialogField field) {
+ return field == fExclusionPatternList;
+ }
+
+ private void addEntry(ListDialogField field) {
+ List existing = field.getElements();
+ ExclusionInclusionEntryDialog dialog = new ExclusionInclusionEntryDialog(
+ getShell(), isExclusion(field), null, existing, fCurrElement);
+ if (dialog.open() == Window.OK) {
+ field.addElement(dialog.getExclusionPattern());
+ }
+ }
+
+ // -------- ExclusionPatternAdapter --------
+ private class ExclusionPatternAdapter implements IListAdapter,
+ IDialogFieldListener {
+ /**
+ * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#customButtonPressed(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField,
+ * int)
+ */
+ public void customButtonPressed(ListDialogField field, int index) {
+ doCustomButtonPressed(field, index);
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#selectionChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField)
+ */
+ public void selectionChanged(ListDialogField field) {
+ doSelectionChanged(field);
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#doubleClicked(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField)
+ */
+ public void doubleClicked(ListDialogField field) {
+ doDoubleClicked(field);
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField)
+ */
+ public void dialogFieldChanged(DialogField field) {
+ }
+ }
+
+ protected void doStatusLineUpdate() {
+ }
+
+ protected void checkIfPatternValid() {
+ }
+
+ private IPath[] getPattern(ListDialogField field) {
+ Object[] arr = field.getElements().toArray();
+ Arrays.sort(arr);
+ IPath[] res = new IPath[arr.length];
+ for (int i = 0; i < res.length; i++) {
+ res[i] = new Path((String) arr[i]);
+ }
+ return res;
+ }
+
+ public IPath[] getExclusionPattern() {
+ return getPattern(fExclusionPatternList);
+ }
+
+ public IPath[] getInclusionPattern() {
+ return getPattern(fInclusionPatternList);
+ }
+
+ /*
+ * @see org.eclipse.jface.window.Window#configureShell(Shell)
+ */
+ protected void configureShell(Shell newShell) {
+ }
+
+ private void addMultipleEntries(ListDialogField field) {
+ String title, message;
+ if (isExclusion(field)) {
+ title = CodanUIMessages.ExclusionInclusionDialog_ChooseExclusionPattern_title;
+ message = CodanUIMessages.ExclusionInclusionDialog_ChooseExclusionPattern_description;
+ } else {
+ title = CodanUIMessages.ExclusionInclusionDialog_ChooseInclusionPattern_title;
+ message = CodanUIMessages.ExclusionInclusionDialog_ChooseInclusionPattern_description;
+ }
+ IPath[] res = ExclusionInclusionEntryDialog.chooseExclusionPattern(
+ getShell(), fCurrSourceFolder, title, message, null, true);
+ if (res != null) {
+ for (int i = 0; i < res.length; i++) {
+ field.addElement(res[i].toString());
+ }
+ }
+ }
+
+ @Override
+ public void noDefaultAndApplyButton() {
+ super.noDefaultAndApplyButton();
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/Messages.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/Messages.java
deleted file mode 100644
index 4ef5f89..0000000
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/Messages.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 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
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Berthold Daum
- *******************************************************************************/
-
-package org.eclipse.cdt.codan.internal.ui.preferences;
-
-import java.util.ResourceBundle;
-
-
-public class Messages {
-
- private final static String RESOURCE_BUNDLE = "org.eclipse.cdt.codan.internal.ui.preferences.Messages";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle = null;
-
- private static boolean notRead = true;
-
- public Messages() {
- }
- public static ResourceBundle getResourceBundle() {
- if (notRead) {
- notRead = false;
- try {
- fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
- }
- catch (Exception e) {
- }
- }
-
- return fgResourceBundle;
- }
- public static String getString(String key) {
- try {
- return getResourceBundle().getString(key);
- } catch (Exception e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-}
-
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/Messages.properties b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/Messages.properties
deleted file mode 100644
index 689b7ee..0000000
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/Messages.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-OverlayPage.Use_Workspace_Settings=Use &workspace settings
-OverlayPage.Use_Project_Settings=Use pr&oject settings
-OverlayPage.Configure_Workspace_Settings=&Configure Workspace Settings ...
-PropertyStore.Cannot_write_resource_property=Cannot write resource property
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/PreferenceInitializer.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/PreferenceInitializer.java
index 4362098..645a892 100644
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/PreferenceInitializer.java
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/PreferenceInitializer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 Alena Laskavaia
* 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
@@ -11,6 +11,7 @@
package org.eclipse.cdt.codan.internal.ui.preferences;
import org.eclipse.cdt.codan.core.PreferenceConstants;
+import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -18,16 +19,16 @@ import org.eclipse.jface.preference.IPreferenceStore;
* Class used to initialize default preference values.
*/
public class PreferenceInitializer extends AbstractPreferenceInitializer {
-
/*
* (non-Javadoc)
*
- * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#
+ * initializeDefaultPreferences()
*/
public void initializeDefaultPreferences() {
- IPreferenceStore store = org.eclipse.cdt.codan.ui.Activator
- .getDefault().getPreferenceStore();
+ IPreferenceStore store = CodanUIActivator.getDefault()
+ .getPreferenceStore();
store.setDefault(PreferenceConstants.P_RUN_ON_BUILD, false);
+ store.setDefault(PreferenceConstants.P_RUN_IN_EDITOR, true);
}
-
}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java
index 26e433e..4547028 100644
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 Alena Laskavaia
* 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
@@ -14,24 +14,27 @@ import org.eclipse.cdt.codan.core.PreferenceConstants;
import org.eclipse.cdt.codan.core.model.CodanSeverity;
import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.core.model.IProblemCategory;
+import org.eclipse.cdt.codan.core.model.IProblemElement;
import org.eclipse.cdt.codan.core.model.IProblemProfile;
+import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
import org.eclipse.cdt.codan.internal.core.CodanPreferencesLoader;
-import org.eclipse.jface.viewers.BaseLabelProvider;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ComboBoxCellEditor;
import org.eclipse.jface.viewers.EditingSupport;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.ICheckStateProvider;
import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
public class ProblemsTreeEditor extends CheckedTreeEditor {
private CodanPreferencesLoader codanPreferencesLoader = new CodanPreferencesLoader();
@@ -136,39 +139,26 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
}
}
+ @Override
public void checkStateChanged(CheckStateChangedEvent event) {
Object element = event.getElement();
- if (element instanceof IProblem) {
- ((IProblem) element).setEnabled(event.getChecked());
- }
- }
-
- class ProblemsLabelProvider extends BaseLabelProvider implements
- IBaseLabelProvider, ITableLabelProvider {
- public Image getColumnImage(Object element, int columnIndex) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- if (element instanceof IProblem) {
- IProblem p = (IProblem) element;
- if (columnIndex == 0)
- return p.getName();
- if (columnIndex == 1)
- return p.getSeverity().toString();
- }
- if (element instanceof IProblemCategory) {
- IProblemCategory p = (IProblemCategory) element;
- if (columnIndex == 0)
- return p.getName();
+ if (element instanceof IProblemWorkingCopy) {
+ ((IProblemWorkingCopy) element).setEnabled(event.getChecked());
+ } else if (element instanceof IProblemCategory) {
+ IProblemCategory cat = (IProblemCategory) element;
+ IProblemElement[] children = cat.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ IProblemElement pe = children[i];
+ checkStateChanged(new CheckStateChangedEvent(getTreeViewer(),
+ pe, event.getChecked()));
}
- return null;
}
+ getTreeViewer().refresh();
}
public ProblemsTreeEditor(Composite parent, IProblemProfile profile) {
- super(PreferenceConstants.P_PROBLEMS, "Problems", parent);
+ super(PreferenceConstants.P_PROBLEMS,
+ CodanUIMessages.ProblemsTreeEditor_Problems, parent);
setEmptySelectionAllowed(true);
getTreeViewer().getTree().setHeaderVisible(true);
// getTreeViewer().getTree().
@@ -178,8 +168,10 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
TreeViewerColumn column1 = new TreeViewerColumn(getTreeViewer(),
SWT.NONE);
column1.getColumn().setWidth(300);
- column1.getColumn().setText("Name");
+ column1.getColumn().setText(
+ CodanUIMessages.ProblemsTreeEditor_NameColumn);
column1.setLabelProvider(new ColumnLabelProvider() {
+ @Override
public String getText(Object element) {
if (element instanceof IProblem) {
IProblem p = (IProblem) element;
@@ -196,8 +188,31 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
TreeViewerColumn column2 = new TreeViewerColumn(getTreeViewer(),
SWT.NONE);
column2.getColumn().setWidth(100);
- column2.getColumn().setText("Severity");
+ column2.getColumn().setText(
+ CodanUIMessages.ProblemsTreeEditor_SeverityColumn);
column2.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public Image getImage(Object element) {
+ final ISharedImages images = PlatformUI.getWorkbench()
+ .getSharedImages();
+ if (element instanceof IProblem) {
+ IProblem p = (IProblem) element;
+ switch (p.getSeverity().intValue()) {
+ case IMarker.SEVERITY_INFO:
+ return images
+ .getImage(ISharedImages.IMG_OBJS_INFO_TSK);
+ case IMarker.SEVERITY_WARNING:
+ return images
+ .getImage(ISharedImages.IMG_OBJS_WARN_TSK);
+ case IMarker.SEVERITY_ERROR:
+ return images
+ .getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+ }
+ }
+ return null;
+ }
+
+ @Override
public String getText(Object element) {
if (element instanceof IProblem) {
IProblem p = (IProblem) element;
@@ -207,23 +222,27 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
}
});
column2.setEditingSupport(new EditingSupport(getTreeViewer()) {
+ @Override
protected boolean canEdit(Object element) {
return element instanceof IProblem;
}
+ @Override
protected CellEditor getCellEditor(Object element) {
return new ComboBoxCellEditor(getTreeViewer().getTree(),
CodanSeverity.stringValues());
}
+ @Override
protected Object getValue(Object element) {
return ((IProblem) element).getSeverity().intValue();
}
+ @Override
protected void setValue(Object element, Object value) {
int index = ((Integer) value).intValue();
CodanSeverity val = CodanSeverity.values()[index];
- ((IProblem) element).setSeverity(val);
+ ((IProblemWorkingCopy) element).setSeverity(val);
getTreeViewer().update(element, null);
}
});
@@ -245,6 +264,9 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
for (int i = 0; i < probs.length; i++) {
String id = probs[i].getId();
String s = getPreferenceStore().getString(id);
+ if (s == null || s.length() == 0) {
+ s = codanPreferencesLoader.getProperty(id);
+ }
codanPreferencesLoader.setProperty(id, s);
}
getViewer().setInput(codanPreferencesLoader.getInput());
@@ -258,6 +280,9 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
for (int i = 0; i < probs.length; i++) {
String id = probs[i].getId();
String s = getPreferenceStore().getDefaultString(id);
+ if (s == null || s.length() == 0) {
+ s = codanPreferencesLoader.getProperty(id);
+ }
codanPreferencesLoader.setProperty(id, s);
}
getViewer().setInput(codanPreferencesLoader.getInput());
@@ -272,12 +297,17 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
*/
@Override
protected void doStore() {
- codanPreferencesLoader.setInput(getViewer().getInput());
+ codanPreferencesLoader.setInput((IProblemProfile) getViewer()
+ .getInput());
IProblem[] probs = codanPreferencesLoader.getProblems();
for (int i = 0; i < probs.length; i++) {
String id = probs[i].getId();
String s = codanPreferencesLoader.getProperty(id);
getPreferenceStore().setValue(id, s);
+ String params = codanPreferencesLoader.getPreferencesString(id);
+ if (params != null)
+ getPreferenceStore().setValue(
+ codanPreferencesLoader.getPreferencesKey(id), params);
}
}
@@ -301,6 +331,6 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
*/
@Override
protected String modelToString(Object model) {
- return "";
+ return ""; //$NON-NLS-1$
}
}