Author: akazakov
Date: 2010-08-03 15:56:14 -0400 (Tue, 03 Aug 2010)
New Revision: 23888
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/SeverityPreferencesMessages.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/preferences/SeverityPreferencesMessages.properties
Log:
https://jira.jboss.org/browse/JBIDE-6507 Enable/disable checkbox has been added to
CDI/EL/Seam validation preference pages.
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 2010-08-03
19:55:27 UTC (rev 23887)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/preferences/SeverityPreferencePage.java 2010-08-03
19:56:14 UTC (rev 23888)
@@ -13,14 +13,27 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage;
+import org.eclipse.jface.dialogs.ControlEnableState;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+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.jboss.tools.common.preferences.SeverityPreferences;
/**
* @author Viacheslav Kabanovich
*/
public abstract class SeverityPreferencePage extends PropertyAndPreferencePage {
+ private ControlEnableState mainBlockEnableState;
+ private Button checkBox;
+ protected Control severityConfigurationBlock;
+
protected SeverityConfigurationBlock fConfigurationBlock;
protected SeverityConfigurationBlock getConfigurationBlock() {
@@ -29,9 +42,51 @@
@Override
protected Control createPreferenceContent(Composite composite) {
- return getConfigurationBlock().createContents(composite);
+ Composite root = new Composite(composite, SWT.NONE);
+
+ GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);
+
+ GridLayout gridLayout = new GridLayout(1, false);
+ root.setLayout(gridLayout);
+ root.setLayoutData(gd);
+
+ 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);
+ gridLayout = new GridLayout(1, false);
+ severityConfigurationBlock.setLayoutData(gd);
+
+ checkBox.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ enableMainPreferenceContent(checkBox.getSelection());
+ getPreferenceStore().setValue(SeverityPreferences.ENABLE_BLOCK_PREFERENCE_NAME,
checkBox.getSelection());
+ }
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+ enableMainPreferenceContent(checkBox.getSelection());
+
+ return root;
}
+ protected void enableMainPreferenceContent(boolean enable) {
+ if (enable) {
+ if (mainBlockEnableState != null) {
+ mainBlockEnableState.restore();
+ mainBlockEnableState= null;
+ }
+ } else {
+ if (mainBlockEnableState == null) {
+ mainBlockEnableState= ControlEnableState.disable(severityConfigurationBlock);
+ }
+ }
+ }
+
@Override
protected boolean hasProjectSpecificOptions(IProject project) {
return getConfigurationBlock().hasProjectSpecificOptions(project);
@@ -64,6 +119,8 @@
*/
@Override
protected void performDefaults() {
+ checkBox.setSelection(true);
+ enableMainPreferenceContent(true);
super.performDefaults();
if (getConfigurationBlock() != null) {
getConfigurationBlock().performDefaults();
@@ -77,7 +134,8 @@
public boolean performOk() {
if (getConfigurationBlock() != null && !getConfigurationBlock().performOk()) {
return false;
- }
+ }
+ updateEnableBlock();
return super.performOk();
}
@@ -89,5 +147,14 @@
if (getConfigurationBlock() != null) {
getConfigurationBlock().performApply();
}
+ updateEnableBlock();
}
+
+ private void updateEnableBlock() {
+ boolean oldValue =
getPreferenceStore().getBoolean(SeverityPreferences.ENABLE_BLOCK_PREFERENCE_NAME);
+ boolean newValue = checkBox.getSelection();
+ if(oldValue != newValue) {
+ getPreferenceStore().setValue(SeverityPreferences.ENABLE_BLOCK_PREFERENCE_NAME,
newValue);
+ }
+ }
}
\ No newline at end of file
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/preferences/SeverityPreferencesMessages.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/preferences/SeverityPreferencesMessages.java 2010-08-03
19:55:27 UTC (rev 23887)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/preferences/SeverityPreferencesMessages.java 2010-08-03
19:56:14 UTC (rev 23888)
@@ -27,6 +27,7 @@
public static String VALIDATOR_CONFIGURATION_BLOCK_ERROR;
public static String VALIDATOR_CONFIGURATION_BLOCK_IGNORE;
public static String VALIDATOR_CONFIGURATION_BLOCK_WARNING;
+ public static String ENABLE_VALIDATION;
static {
NLS.initializeMessages(BUNDLE_NAME, SeverityPreferencesMessages.class);
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/preferences/SeverityPreferencesMessages.properties
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/preferences/SeverityPreferencesMessages.properties 2010-08-03
19:55:27 UTC (rev 23887)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/preferences/SeverityPreferencesMessages.properties 2010-08-03
19:56:14 UTC (rev 23888)
@@ -16,4 +16,6 @@
VALIDATOR_CONFIGURATION_BLOCK_ERROR=Error
VALIDATOR_CONFIGURATION_BLOCK_WARNING=Warning
-VALIDATOR_CONFIGURATION_BLOCK_IGNORE=Ignore
\ No newline at end of file
+VALIDATOR_CONFIGURATION_BLOCK_IGNORE=Ignore
+
+ENABLE_VALIDATION=Enable validation
\ No newline at end of file