[jbosstools-commits] JBoss Tools SVN: r44103 - trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/preferences.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Thu Sep 27 13:17:17 EDT 2012
Author: akazakov
Date: 2012-09-27 13:17:17 -0400 (Thu, 27 Sep 2012)
New Revision: 44103
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/preferences/SeverityConfigurationBlock.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/preferences/SeverityPreferencePage.java
Log:
https://issues.jboss.org/browse/JBIDE-12741 CDI (and other JBT common validators) is disabled for workspace if you disable it for project
Modified: trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/preferences/SeverityConfigurationBlock.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/preferences/SeverityConfigurationBlock.java 2012-09-27 17:16:45 UTC (rev 44102)
+++ trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/preferences/SeverityConfigurationBlock.java 2012-09-27 17:17:17 UTC (rev 44103)
@@ -89,12 +89,22 @@
*/
protected Text filterControl;
+ protected IWorkbenchPreferenceContainer container;
+
public SeverityConfigurationBlock(IStatusChangeListener context,
IProject project, Key[] allKeys,
IWorkbenchPreferenceContainer container) {
super(context, project, allKeys, container);
+ this.container = container;
}
+ /**
+ * @return the container
+ */
+ public IWorkbenchPreferenceContainer getContainer() {
+ return container;
+ }
+
protected abstract String getCommonDescription();
protected abstract SectionDescription[] getAllSections();
Modified: trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/preferences/SeverityPreferencePage.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/preferences/SeverityPreferencePage.java 2012-09-27 17:16:45 UTC (rev 44102)
+++ trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/preferences/SeverityPreferencePage.java 2012-09-27 17:17:17 UTC (rev 44103)
@@ -12,6 +12,11 @@
package org.jboss.tools.common.ui.preferences;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage;
import org.eclipse.jface.dialogs.ControlEnableState;
import org.eclipse.jface.resource.JFaceResources;
@@ -23,6 +28,9 @@
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+import org.eclipse.ui.preferences.IWorkingCopyManager;
+import org.eclipse.ui.preferences.WorkingCopyManager;
import org.jboss.tools.common.preferences.SeverityPreferences;
import org.jboss.tools.common.ui.preferences.SeverityConfigurationBlock.OptionDescription;
import org.jboss.tools.common.ui.preferences.SeverityConfigurationBlock.SectionDescription;
@@ -55,16 +63,44 @@
checkBox = new Button(root, SWT.CHECK);
checkBox.setFont(JFaceResources.getDialogFont());
checkBox.setText(SeverityPreferencesMessages.ENABLE_VALIDATION);
- checkBox.setSelection(getPreferenceStore().getBoolean(SeverityPreferences.ENABLE_BLOCK_PREFERENCE_NAME));
severityConfigurationBlock = getConfigurationBlock().createContents(root);
+
+ IScopeContext[] lookupOrder;
+ IProject project = getProject();
+ if (project != null) {
+ lookupOrder = new IScopeContext[] {
+ new ProjectScope(project),
+ InstanceScope.INSTANCE,
+ DefaultScope.INSTANCE
+ };
+ } else {
+ lookupOrder = new IScopeContext[] {
+ InstanceScope.INSTANCE,
+ DefaultScope.INSTANCE
+ };
+ }
+ final IScopeContext context = lookupOrder[0];
+ IWorkbenchPreferenceContainer container = getConfigurationBlock().getContainer();
+
+ final IWorkingCopyManager manager;
+ if (container == null) {
+ manager = new WorkingCopyManager();
+ } else {
+ manager = container.getWorkingCopyManager();
+ }
+ String value = getStoredValue(lookupOrder, manager, getConfigurationBlock().getQualifier(), SeverityPreferences.ENABLE_BLOCK_PREFERENCE_NAME);
+ boolean enabled = value==null?true:Boolean.parseBoolean(value);
+
+ checkBox.setSelection(enabled);
+
gridLayout = new GridLayout(1, false);
severityConfigurationBlock.setLayoutData(gd);
checkBox.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
enableMainPreferenceContent(checkBox.getSelection());
- getPreferenceStore().setValue(SeverityPreferences.ENABLE_BLOCK_PREFERENCE_NAME, checkBox.getSelection());
+ setStoredValue(context, Boolean.toString(checkBox.getSelection()), manager, getConfigurationBlock().getQualifier(), SeverityPreferences.ENABLE_BLOCK_PREFERENCE_NAME);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
@@ -74,6 +110,36 @@
return root;
}
+ private IEclipsePreferences getNode(IScopeContext context, IWorkingCopyManager manager, String qualifier) {
+ IEclipsePreferences node= context.getNode(qualifier);
+ if (manager != null) {
+ return manager.getWorkingCopy(node);
+ }
+ return node;
+ }
+
+ public String getStoredValue(IScopeContext context, IWorkingCopyManager manager, String qualifier, String key) {
+ return getNode(context, manager, qualifier).get(key, null);
+ }
+
+ public String getStoredValue(IScopeContext[] lookupOrder, IWorkingCopyManager manager, String qualifier, String key) {
+ for (int i = 0; i < lookupOrder.length; i++) {
+ String value= getStoredValue(lookupOrder[i], manager, qualifier, key);
+ if (value != null) {
+ return value;
+ }
+ }
+ return null;
+ }
+
+ public void setStoredValue(IScopeContext context, String value, IWorkingCopyManager manager, String qualifier, String key) {
+ if (value != null) {
+ getNode(context, manager, qualifier).put(key, value);
+ } else {
+ getNode(context, manager, qualifier).remove(key);
+ }
+ }
+
protected void enableMainPreferenceContent(boolean enable) {
if (enable) {
if (mainBlockEnableState != null) {
More information about the jbosstools-commits
mailing list