Author: scabanovich
Date: 2012-05-09 20:03:14 -0400 (Wed, 09 May 2012)
New Revision: 40898
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/internal/preferences/ELSearchPreferencePage.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.properties
trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/internal/preferences/Messages.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/internal/preferences/preferences.properties
Log:
JBIDE-11682
https://issues.jboss.org/browse/JBIDE-11682
Preference 'Search time limit' is added.
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.properties 2012-05-09 23:56:18 UTC
(rev 40897)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.properties 2012-05-10 00:03:14 UTC
(rev 40898)
@@ -57,4 +57,6 @@
PreferencePage_Validator = Validation
PropertiesPage_Validator = Expression Language Validation
-PreferencePage_WebXML_Validator = Web XML Validation
\ No newline at end of file
+PreferencePage_WebXML_Validator = Web XML Validation
+
+PreferencePage_Search = Search and Refactoring
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml 2012-05-09 23:56:18 UTC (rev
40897)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml 2012-05-10 00:03:14 UTC (rev
40898)
@@ -66,6 +66,11 @@
class="org.jboss.tools.jst.web.ui.internal.preferences.ELValidatorPreferencePage"
id="org.jboss.tools.jst.web.ui.preferences.ELValidatorPreferencePage"
name="%PreferencePage_Validator"/>
+ <page
+ category="org.jboss.tools.el.ui"
+
class="org.jboss.tools.jst.web.ui.internal.preferences.ELSearchPreferencePage"
+
id="org.jboss.tools.jst.web.ui.internal.preferences.ELSearchPreferencePage"
+ name="%PreferencePage_Search"/>
</extension>
<extension
point="org.eclipse.ui.propertyPages">
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/internal/preferences/ELSearchPreferencePage.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/internal/preferences/ELSearchPreferencePage.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/internal/preferences/ELSearchPreferencePage.java 2012-05-10
00:03:14 UTC (rev 40898)
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.ui.internal.preferences;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.IOException;
+
+import org.eclipse.jface.preference.IPersistentPreferenceStore;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.jboss.tools.common.ui.widget.editor.IFieldEditor;
+import org.jboss.tools.common.ui.widget.editor.SwtFieldEditorFactory;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+import org.jboss.tools.jst.web.kb.preferences.ELSearchPreferences;
+
+/**
+ * Preference page for EL Search preferences
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class ELSearchPreferencePage extends PreferencePage implements
+ IWorkbenchPreferencePage {
+
+ private IWorkbench workbench;
+ IFieldEditor timeLimit;
+
+ @Override
+ protected Control createContents(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ composite.setLayout(layout);
+
+ timeLimit = SwtFieldEditorFactory.INSTANCE.createTextEditor("timeLimit",
//$NON-NLS-1$
+ Messages.ELSearchPreferencePage_searchTimeLimit,
+ getPreferenceStore().getString(ELSearchPreferences.EL_SEARCH_TIME_LIMIT));
+ timeLimit.doFillIntoGrid(composite);
+
+ timeLimit.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ validate();
+ }
+ });
+ validate();
+
+ return composite;
+ }
+
+ public void init(IWorkbench workbench) {
+ this.workbench = workbench;
+ }
+
+ protected void validate() {
+ if(timeLimit == null) {
+ return;
+ }
+ String error = null;
+ String value = timeLimit.getValueAsString();
+ try {
+ int v = Integer.parseInt(value);
+ if(v < 0) {
+ error = Messages.ELSearchPreferencePage_searchTimeLimit_invalid;
+ }
+ } catch (NumberFormatException e) {
+ error = Messages.ELSearchPreferencePage_searchTimeLimit_invalid;
+ }
+ setErrorMessage(error);
+ setValid(error == null);
+ }
+
+ @Override
+ protected void performDefaults() {
+ IPreferenceStore store = getPreferenceStore();
+
+ String defaultValue =
store.getDefaultString(ELSearchPreferences.EL_SEARCH_TIME_LIMIT);
+ timeLimit.setValue(defaultValue);
+ store.setValue(ELSearchPreferences.EL_SEARCH_TIME_LIMIT, defaultValue);
+
+ if (store instanceof IPersistentPreferenceStore) {
+ try {
+ ((IPersistentPreferenceStore)store).save();
+ } catch (IOException e) {
+ WebKbPlugin.getDefault().logError(e);
+ }
+ }
+
+ super.performDefaults();
+ }
+
+ @Override
+ public boolean performOk() {
+ if(!isValid()) {
+ return false;
+ }
+ IPreferenceStore store = getPreferenceStore();
+ store.setValue(ELSearchPreferences.EL_SEARCH_TIME_LIMIT,
timeLimit.getValueAsString());
+
+ if (store instanceof IPersistentPreferenceStore) {
+ try {
+ ((IPersistentPreferenceStore)store).save();
+ } catch (IOException e) {
+ WebKbPlugin.getDefault().logError(e);
+ }
+ }
+
+ return super.performOk();
+ }
+
+ protected IPreferenceStore doGetPreferenceStore() {
+ return WebKbPlugin.getDefault().getPreferenceStore();
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/internal/preferences/ELSearchPreferencePage.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/internal/preferences/Messages.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/internal/preferences/Messages.java 2012-05-09
23:56:18 UTC (rev 40897)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/internal/preferences/Messages.java 2012-05-10
00:03:14 UTC (rev 40898)
@@ -21,6 +21,8 @@
public static String ImplementationsPreferencesPage_Project_Templates;
public static String ContentAssistPreferencePage_showGettersAndSetters;
public static String ContentAssistPreferencePage_showMethodsWithParenthesesOnly;
+ public static String ELSearchPreferencePage_searchTimeLimit;
+ public static String ELSearchPreferencePage_searchTimeLimit_invalid;
private Messages() {
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/internal/preferences/preferences.properties
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/internal/preferences/preferences.properties 2012-05-09
23:56:18 UTC (rev 40897)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/internal/preferences/preferences.properties 2012-05-10
00:03:14 UTC (rev 40898)
@@ -14,4 +14,6 @@
ImplementationsPreferencesPage_Library_Sets=Library Sets
ImplementationsPreferencesPage_Project_Templates=Project Templates
ContentAssistPreferencePage_showGettersAndSetters=Show Getters and Setters for the
properties
-ContentAssistPreferencePage_showMethodsWithParenthesesOnly=Show Methods Only with
Parentheses
\ No newline at end of file
+ContentAssistPreferencePage_showMethodsWithParenthesesOnly=Show Methods Only with
Parentheses
+ELSearchPreferencePage_searchTimeLimit=Search time limit in seconds:
+ELSearchPreferencePage_searchTimeLimit_invalid=The value must be a positive integer.
\ No newline at end of file