diff options
author | Curtis D'Entremont | 2006-09-06 15:42:38 +0000 |
---|---|---|
committer | Curtis D'Entremont | 2006-09-06 15:42:38 +0000 |
commit | e303c6ad1f2edea03bfdd63c0b123376db46e5af (patch) | |
tree | 93cbfc9520e7a3a57d8c3ea231f646e3948f716a /org.eclipse.help.ui | |
parent | 4f78090d6f7d3ca0f828e837181298a4668d8fb5 (diff) | |
download | eclipse.platform.ua-e303c6ad1f2edea03bfdd63c0b123376db46e5af.tar.gz eclipse.platform.ua-e303c6ad1f2edea03bfdd63c0b123376db46e5af.tar.xz eclipse.platform.ua-e303c6ad1f2edea03bfdd63c0b123376db46e5af.zip |
122967 [Help] Remote help system (search and preference page parts)
Diffstat (limited to 'org.eclipse.help.ui')
-rw-r--r-- | org.eclipse.help.ui/plugin.properties | 6 | ||||
-rw-r--r-- | org.eclipse.help.ui/plugin.xml | 6 | ||||
-rw-r--r-- | org.eclipse.help.ui/src/org/eclipse/help/ui/internal/AppserverPreferencePage.java | 181 | ||||
-rw-r--r-- | org.eclipse.help.ui/src/org/eclipse/help/ui/internal/IHelpUIConstants.java | 8 | ||||
-rw-r--r-- | org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.java | 41 | ||||
-rw-r--r-- | org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.properties | 50 | ||||
-rw-r--r-- | org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/HelpContentPreferencePage.java | 261 | ||||
-rw-r--r-- | org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/HelpPreferencePage.java (renamed from org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/BrowsersPreferencePage.java) | 34 |
8 files changed, 334 insertions, 253 deletions
diff --git a/org.eclipse.help.ui/plugin.properties b/org.eclipse.help.ui/plugin.properties index c72c18f26..7b5d2aea7 100644 --- a/org.eclipse.help.ui/plugin.properties +++ b/org.eclipse.help.ui/plugin.properties @@ -10,15 +10,15 @@ ############################################################################### help_system_plugin_name = Help System UI providerName=Eclipse.org + +# Preference pages help_preferences_page_name = Help +remote_help_preferences_page_name = Content # Browser adapters embedded_browser = Embedded Browser system_browser = Default System Browser -# Application Server -appserver_preferences_page_name= Help Server - # Preference Keywords preferenceKeywords.browsersPreferencePage=Help Web Browser Infopop F1 preferenceKeywords.appserverPreferencePage=Help Application Server diff --git a/org.eclipse.help.ui/plugin.xml b/org.eclipse.help.ui/plugin.xml index 929e5318c..89fa72381 100644 --- a/org.eclipse.help.ui/plugin.xml +++ b/org.eclipse.help.ui/plugin.xml @@ -16,14 +16,14 @@ point="org.eclipse.ui.preferencePages"> <page name="%help_preferences_page_name" - class="org.eclipse.help.ui.internal.browser.BrowsersPreferencePage" + class="org.eclipse.help.ui.internal.preferences.HelpPreferencePage" id="org.eclipse.help.ui.browsersPreferencePage"> <keywordReference id="org.eclipse.help.ui.browsersPreferencePage"/> </page> <page - name="%appserver_preferences_page_name" + name="%remote_help_preferences_page_name" category="org.eclipse.help.ui.browsersPreferencePage" - class="org.eclipse.help.ui.internal.AppserverPreferencePage" + class="org.eclipse.help.ui.internal.preferences.HelpContentPreferencePage" id="org.eclipse.help.ui.appserverPreferencePage"> <keywordReference id="org.eclipse.help.ui.appserverPreferencePage"/> </page> diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/AppserverPreferencePage.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/AppserverPreferencePage.java deleted file mode 100644 index 9be8b0250..000000000 --- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/AppserverPreferencePage.java +++ /dev/null @@ -1,181 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.ui.internal; -import org.eclipse.core.runtime.Preferences; -import org.eclipse.help.internal.appserver.AppserverPlugin; -import org.eclipse.jface.preference.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.*; -import org.eclipse.ui.forms.HyperlinkSettings; -import org.eclipse.ui.forms.widgets.FormText; - -/** - * Preference page for Tomcat network interface and port. - */ -public class AppserverPreferencePage extends PreferencePage - implements - IWorkbenchPreferencePage { - protected Text textServerAddr; - protected Text textServerPort; - /** - * Creates preference page controls on demand. - * - * @param parent - * the parent for the preference page - */ - protected Control createContents(Composite parent) { - Font font = parent.getFont(); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IHelpUIConstants.PREF_PAGE_APPSERVER); - - final Composite mainComposite = new Composite(parent, SWT.NULL); - mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); - final GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.numColumns = 2; - mainComposite.setLayout(layout); - - final Label descLabel = new Label(mainComposite, SWT.WRAP); - descLabel.setText(Messages.AppserverPreferencePage_description); - GridData data = new GridData(); - data.horizontalSpan = 2; - data.widthHint = 100; - data.heightHint = 20; - descLabel.setLayoutData(data); - descLabel.setFont(font); - - // Spacer - Label label = new Label(mainComposite, SWT.NONE); - data = new GridData(); - data.horizontalSpan = 2; - label.setLayoutData(data); - label.setFont(font); - - label = new Label(mainComposite, SWT.NONE); - label.setFont(font); - label.setText(Messages.AppserverPreferencePage_hostDescription); - - textServerAddr = new Text(mainComposite, SWT.SINGLE | SWT.BORDER); - //text.addListener(SWT.Modify, this); - data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = convertWidthInCharsToPixels(8); - textServerAddr.setLayoutData(data); - textServerAddr.setFont(font); - - label = new Label(mainComposite, SWT.NONE); - label.setFont(font); - label.setText(Messages.AppserverPreferencePage_portDescription); - - textServerPort = new Text(mainComposite, SWT.SINGLE | SWT.BORDER); - textServerPort.setTextLimit(5); - data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = convertWidthInCharsToPixels(8); - textServerPort.setLayoutData(data); - textServerPort.setFont(font); - - // Validation of port field - textServerPort.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (textServerPort.getText().length() == 0) { - AppserverPreferencePage.this.setValid(true); - setErrorMessage(null); - return; - } - try { - int num = Integer.valueOf(textServerPort.getText()) - .intValue(); - if (0 <= num && num <= 0xFFFF) { - // port is valid - AppserverPreferencePage.this.setValid(true); - setErrorMessage(null); - return; - } - - // port is invalid - } catch (NumberFormatException nfe) { - } - AppserverPreferencePage.this.setValid(false); - setErrorMessage(Messages.AppserverPreferencePage_invalidPort); - } - }); - - // Spacer - label = new Label(mainComposite, SWT.NONE); - data = new GridData(); - data.horizontalSpan = 2; - label.setLayoutData(data); - label.setFont(font); - - FormText ftext = new FormText(mainComposite, SWT.WRAP); - ftext.setText(Messages.AppserverPreferencePage_requireRestart, true, false); - data = new GridData(GridData.GRAB_HORIZONTAL); - ftext.setHyperlinkSettings(new HyperlinkSettings(mainComposite.getDisplay())); - data.horizontalSpan = 2; - data.widthHint = 100; - data.heightHint = 20; - ftext.setLayoutData(data); - ftext.setFont(font); - final GridData fdata = data; - mainComposite.addControlListener(new ControlAdapter() { - public void controlResized(ControlEvent e) { - GridData ddata = (GridData)descLabel.getLayoutData(); - int width = mainComposite.getSize().x-layout.marginWidth*2; - fdata.widthHint = width; - fdata.heightHint = SWT.DEFAULT; - ddata.widthHint = width; - ddata.heightHint = SWT.DEFAULT; - mainComposite.layout(); - } - }); - - Preferences pref = AppserverPlugin.getDefault().getPluginPreferences(); - textServerAddr.setText(pref.getString(AppserverPlugin.HOST_KEY)); - textServerPort.setText(pref.getString(AppserverPlugin.PORT_KEY)); - - return mainComposite; - } - /** - * @see IWorkbenchPreferencePage - */ - public void init(IWorkbench workbench) { - } - /** - * Performs special processing when this page's Defaults button has been - * pressed. - * <p> - * This is a framework hook method for sublcasses to do special things when - * the Defaults button has been pressed. Subclasses may override, but should - * call <code>super.performDefaults</code>. - * </p> - */ - protected void performDefaults() { - Preferences pref = AppserverPlugin.getDefault().getPluginPreferences(); - textServerAddr.setText(pref.getDefaultString(AppserverPlugin.HOST_KEY)); - textServerPort.setText(pref.getDefaultString(AppserverPlugin.PORT_KEY)); - super.performDefaults(); - } - /** - * @see IPreferencePage - */ - public boolean performOk() { - Preferences pref = AppserverPlugin.getDefault().getPluginPreferences(); - pref.setValue(AppserverPlugin.HOST_KEY, textServerAddr.getText()); - pref.setValue(AppserverPlugin.PORT_KEY, textServerPort.getText()); - AppserverPlugin.getDefault().savePluginPreferences(); - return true; - } - -} diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/IHelpUIConstants.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/IHelpUIConstants.java index d8ce74ba4..9647b1964 100644 --- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/IHelpUIConstants.java +++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/IHelpUIConstants.java @@ -17,10 +17,10 @@ public interface IHelpUIConstants { public static final String HELP_UI_PLUGIN_ID = HelpUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$ // F1 ids public static final String F1_SHELL = HELP_UI_PLUGIN_ID + "f1Shell"; //$NON-NLS-1$ - public static final String PREF_PAGE_BROWSERS = HELP_UI_PLUGIN_ID - + "prefPageBrowsers"; //$NON-NLS-1$ - public static final String PREF_PAGE_APPSERVER = HELP_UI_PLUGIN_ID - + "prefPageAppServer"; //$NON-NLS-1$ + public static final String PREF_PAGE_HELP = HELP_UI_PLUGIN_ID + + "prefPageHelp"; //$NON-NLS-1$ + public static final String PREF_PAGE_HELP_CONTENT = HELP_UI_PLUGIN_ID + + "prefPageHelpContent"; //$NON-NLS-1$ public static final String PREF_PAGE_CUSTOM_BROWSER_PATH = HELP_UI_PLUGIN_ID + "prefPageCustomBrowserPath"; //$NON-NLS-1$ diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.java index 930dbc7fa..7ae06340c 100644 --- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.java +++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.java @@ -32,11 +32,6 @@ public final class Messages extends NLS { public static String CustomBrowserPreferencePage_Program; public static String CustomBrowserPreferencePage_Browse; public static String CustomBrowserPreferencePage_Details; - public static String AppserverPreferencePage_description; - public static String AppserverPreferencePage_hostDescription; - public static String AppserverPreferencePage_portDescription; - public static String AppserverPreferencePage_requireRestart; - public static String AppserverPreferencePage_invalidPort; public static String WW002; public static String WE022; public static String WE023; @@ -136,19 +131,19 @@ public final class Messages extends NLS { public static String ScopePreferenceDialog_delete; public static String NewEngineWizard_wtitle; public static String BrowserPart_showExternalTooltip; - public static String BrowsersPreferencePage_message; - public static String BrowsersPreferencePage_winfopop; - public static String BrowsersPreferencePage_dinfopop; + public static String HelpPreferencePage_message; + public static String HelpPreferencePage_winfopop; + public static String HelpPreferencePage_dinfopop; public static String BrowserPart_bookmarkTooltip; public static String BrowserPart_highlightTooltip; public static String BrowserPart_syncTocTooltip; - public static String BrowsersPreferencePage_wlabel; - public static String BrowsersPreferencePage_view; - public static String BrowsersPreferencePage_dlabel; - public static String BrowsersPreferencePage_tray; - public static String BrowsersPreferencePage_search; - public static String BrowsersPreferencePage_searchPotentialHits; - public static String BrowsersPreferencePage_searchActualHits; + public static String HelpPreferencePage_wlabel; + public static String HelpPreferencePage_view; + public static String HelpPreferencePage_dlabel; + public static String HelpPreferencePage_tray; + public static String HelpPreferencePage_search; + public static String HelpPreferencePage_searchPotentialHits; + public static String HelpPreferencePage_searchActualHits; public static String InfoCenterPage_url; public static String InfoCenterPage_invalidURL; public static String InfoCenterPage_tocError; @@ -175,10 +170,10 @@ public final class Messages extends NLS { NLS.initializeMessages(BUNDLE_NAME, Messages.class); } - public static String BrowsersPreferencePage_openModeGroup; - public static String BrowsersPreferencePage_olabel; - public static String BrowsersPreferencePage_openInPlace; - public static String BrowsersPreferencePage_openInEditor; + public static String HelpPreferencePage_openModeGroup; + public static String HelpPreferencePage_olabel; + public static String HelpPreferencePage_openInPlace; + public static String HelpPreferencePage_openInEditor; public static String ReusableHelpPart_internalBrowserTitle; public static String ReusableHelpPart_internalWebBrowserError; public static String ScopeSet_errorLoading; @@ -186,5 +181,13 @@ public final class Messages extends NLS { public static String IndexInstructions; public static String IndexButton; + public static String HelpContentPreferencePage_remote; + public static String HelpContentPreferencePage_location; + public static String HelpContentPreferencePage_host; + public static String HelpContentPreferencePage_portDefault; + public static String HelpContentPreferencePage_port; + public static String HelpContentPreferencePage_error_host; + public static String HelpContentPreferencePage_error_port; + public static String NoWorkbenchForExecuteCommand_msg; } diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.properties b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.properties index 0d6c1d9a2..452f84fe5 100644 --- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.properties +++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.properties @@ -32,18 +32,6 @@ CustomBrowserPreferencePage_Program = Custom Browser &command: CustomBrowserPreferencePage_Browse = &Browse... CustomBrowserPreferencePage_Details = Select a browser program -# AppserverPreferencePage -AppserverPreferencePage_description = Internal Application Server configuration. The server is used internally \ -by help system. -AppserverPreferencePage_hostDescription = &Host name or IP address: -#AppserverPreferencePage.host = &Host: -AppserverPreferencePage_portDescription = Server &port: -#AppserverPreferencePage.port = &Port: -AppserverPreferencePage_requireRestart = <form><p><b>Note:</b> Leave the above fields empty to have the IP address and port number \ -dynamically computed by the help system. If the server is already running, these preferences will only take effect \ -after restarting.</p></form> -AppserverPreferencePage_invalidPort = Port must be a number in the range 0-65535 - # ContextHelpDialog WW002 = No description. @@ -162,28 +150,38 @@ EngineDescriptorManager_errorSaving=Error while saving user searches SearchResultsPart_showCategoriesAction_tooltip=Show result categories SearchResultsPart_showDescriptionAction_tooltip=Show result descriptions +# Preference pages +HelpPreferencePage_message=See <a>''{0}''</a> for configuring the external browser used to display help topics. +HelpPreferencePage_openModeGroup=Open Modes +HelpPreferencePage_winfopop= &in an infopop +HelpPreferencePage_dinfopop=in an in&fopop +HelpPreferencePage_olabel=Open help view documents +HelpPreferencePage_openInPlace=in-&place +HelpPreferencePage_openInEditor=in the &editor area +HelpPreferencePage_wlabel=Open window context help +HelpPreferencePage_view=in a dynamic help &view +HelpPreferencePage_dlabel=Open dialog context help +HelpPreferencePage_tray=in a dialog &tray +HelpPreferencePage_search=Search +HelpPreferencePage_searchPotentialHits=Show all p&otential hits (faster) +HelpPreferencePage_searchActualHits=Show only a&ctual hits + +HelpContentPreferencePage_remote=&Show help content from a remote infocenter +HelpContentPreferencePage_location=&Location +HelpContentPreferencePage_host=&Host: +HelpContentPreferencePage_portDefault=Use &default port +HelpContentPreferencePage_port=Use &port: +HelpContentPreferencePage_error_host=You must specify a hostname +HelpContentPreferencePage_error_port=Port must be an integer between 0 and 65535 + ScopePreferenceDialog_wtitle = Search Scope - {0} ScopePreferenceDialog_new=&New... ScopePreferenceDialog_delete=De&lete NewEngineWizard_wtitle=New Search Engine BrowserPart_showExternalTooltip=Show in external window -BrowsersPreferencePage_message=See <a>''{0}''</a> for configuring the external browser used to display help topics. -BrowsersPreferencePage_openModeGroup=Open Modes -BrowsersPreferencePage_winfopop= &in an infopop -BrowsersPreferencePage_dinfopop=in an in&fopop -BrowsersPreferencePage_olabel=Open help view documents -BrowsersPreferencePage_openInPlace=in-&place -BrowsersPreferencePage_openInEditor=in the &editor area BrowserPart_bookmarkTooltip=Bookmark document BrowserPart_highlightTooltip=Highlight search terms BrowserPart_syncTocTooltip = Show in All Topics -BrowsersPreferencePage_wlabel=Open window context help -BrowsersPreferencePage_view=in a dynamic help &view -BrowsersPreferencePage_dlabel=Open dialog context help -BrowsersPreferencePage_tray=in a dialog &tray -BrowsersPreferencePage_search=Search -BrowsersPreferencePage_searchPotentialHits=Show all p&otential hits (faster) -BrowsersPreferencePage_searchActualHits=Show only a&ctual hits InfoCenterPage_url = &URL: InfoCenterPage_invalidURL=Invalid URL InfoCenterPage_tocError=Error while loading table of contents diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/HelpContentPreferencePage.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/HelpContentPreferencePage.java new file mode 100644 index 000000000..35db50928 --- /dev/null +++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/HelpContentPreferencePage.java @@ -0,0 +1,261 @@ +/******************************************************************************* + * Copyright (c) 2006 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.help.ui.internal.preferences; + +import org.eclipse.core.runtime.Preferences; +import org.eclipse.help.internal.base.HelpBasePlugin; +import org.eclipse.help.internal.base.IHelpBaseConstants; +import org.eclipse.help.ui.internal.IHelpUIConstants; +import org.eclipse.help.ui.internal.Messages; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.swt.SWT; +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.Event; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.PlatformUI; + +/* + * The preference page implementation of Help -> Content. + */ +public class HelpContentPreferencePage extends PreferencePage + implements IWorkbenchPreferencePage { + + private Button checkbox; + private Group group; + private Label hostLabel; + private Text hostText; + private Button radio1; + private Button radio2; + private Text portText; + + /* + * Listens for any change in the UI and checks for valid + * input and correct enablement. + */ + private Listener changeListener = new Listener() { + public void handleEvent(Event event) { + updateEnablement(); + updateValidity(); + } + }; + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) + */ + protected Control createContents(Composite parent) { + PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, + IHelpUIConstants.PREF_PAGE_HELP_CONTENT); + + Composite composite = createComposite(parent); + createCheckbox(composite); + createGroup(composite); + + applyDialogFont(composite); + + // initialize the UI + Preferences prefs = HelpBasePlugin.getDefault().getPluginPreferences(); + String host = prefs.getString(IHelpBaseConstants.P_KEY_REMOTE_HELP_SERVER_HOST); + int port = prefs.getInt(IHelpBaseConstants.P_KEY_REMOTE_HELP_SERVER_PORT); + setValues(host, port); + + return composite; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + public void init(IWorkbench workbench) { + // nothing to do here + } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.PreferencePage#performDefaults() + */ + protected void performDefaults() { + Preferences prefs = HelpBasePlugin.getDefault().getPluginPreferences(); + String host = prefs.getDefaultString(IHelpBaseConstants.P_KEY_REMOTE_HELP_SERVER_HOST); + int port = prefs.getDefaultInt(IHelpBaseConstants.P_KEY_REMOTE_HELP_SERVER_PORT); + setValues(host, port); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.PreferencePage#performOk() + */ + public boolean performOk() { + Preferences prefs = HelpBasePlugin.getDefault().getPluginPreferences(); + if (checkbox.getSelection() == true) { + String host = hostText.getText().trim(); + prefs.setValue(IHelpBaseConstants.P_KEY_REMOTE_HELP_SERVER_HOST, host); + String port; + if (radio2.getSelection()) { + port = portText.getText().trim(); + } + else { + port = String.valueOf(Preferences.INT_DEFAULT_DEFAULT); + } + prefs.setValue(IHelpBaseConstants.P_KEY_REMOTE_HELP_SERVER_PORT, port); + } + else { + prefs.setValue(IHelpBaseConstants.P_KEY_REMOTE_HELP_SERVER_HOST, Preferences.STRING_DEFAULT_DEFAULT); + prefs.setValue(IHelpBaseConstants.P_KEY_REMOTE_HELP_SERVER_PORT, Preferences.INT_DEFAULT_DEFAULT); + } + HelpBasePlugin.getDefault().savePluginPreferences(); + return true; + } + + /* + * Create the Composite that will hold the entire preference page. + */ + private Composite createComposite(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.marginWidth = 0; + layout.marginHeight = 0; + composite.setLayout(layout); + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); + return composite; + } + + /* + * Create the top checkbox. + */ + private void createCheckbox(Composite parent) { + checkbox = new Button(parent, SWT.CHECK); + checkbox.setText(Messages.HelpContentPreferencePage_remote); + checkbox.addListener(SWT.Selection, changeListener); + } + + /* + * Create the "Location" group. + */ + private void createGroup(Composite parent) { + group = new Group(parent, SWT.NONE); + group.setText(Messages.HelpContentPreferencePage_location); + group.setLayout(new GridLayout(2, false)); + group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + + createHostSection(group); + createPortSection(group); + } + + /* + * Create the "Host:" label and text field. + */ + private void createHostSection(Composite parent) { + hostLabel = new Label(parent, SWT.NONE); + hostLabel.setText(Messages.HelpContentPreferencePage_host); + hostText = new Text(parent, SWT.BORDER); + hostText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + hostText.addListener(SWT.Modify, changeListener); + } + + /* + * Create the port radio buttons, and text field. + */ + private void createPortSection(Composite parent) { + Composite portComposite = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(2, false); + layout.marginWidth = 0; + layout.marginHeight = 0; + portComposite.setLayout(layout); + portComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); + + radio1 = new Button(portComposite, SWT.RADIO); + radio1.setText(Messages.HelpContentPreferencePage_portDefault); + radio1.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 2, 1)); + radio1.addListener(SWT.Selection, changeListener); + + radio2 = new Button(portComposite, SWT.RADIO); + radio2.setText(Messages.HelpContentPreferencePage_port); + radio2.addListener(SWT.Selection, changeListener); + + portText = new Text(portComposite, SWT.BORDER); + portText.setLayoutData(new GridData(45, SWT.DEFAULT)); + portText.addListener(SWT.Modify, changeListener); + } + + /* + * Sets the given values for the UI. + */ + private void setValues(String host, int port) { + if (host.length() > 0) { + checkbox.setSelection(true); + hostText.setText(host); + } + radio1.setSelection(port == Preferences.INT_DEFAULT_DEFAULT); + radio2.setSelection(port != Preferences.INT_DEFAULT_DEFAULT); + if (port != 0) { + portText.setText(String.valueOf(port)); + } + updateEnablement(); + updateValidity(); + } + + /* + * Ensures that the correct controls are grayed out and disabled, and the + * rest are enabled. + */ + private void updateEnablement() { + boolean isChecked = checkbox.getSelection(); + group.setEnabled(isChecked); + hostLabel.setEnabled(isChecked); + hostText.setEnabled(isChecked); + radio1.setEnabled(isChecked); + radio2.setEnabled(isChecked); + portText.setEnabled(isChecked && radio2.getSelection()); + } + + /* + * Checks for errors in the user input and shows/clears the error message + * as appropriate. + */ + private void updateValidity() { + // no checking needed if remote not selected + if (checkbox.getSelection() == true) { + // check for empty hostname + if (hostText.getText().trim().length() == 0) { + setErrorMessage(Messages.HelpContentPreferencePage_error_host); + setValid(false); + return; + } + // check for invalid port + if (radio2.getSelection() == true) { + try { + // check port range + int port = Integer.parseInt(portText.getText()); + if (port < 0 || port > 65535) { + setErrorMessage(Messages.HelpContentPreferencePage_error_port); + setValid(false); + return; + } + } + catch (NumberFormatException e) { + // not a number + setErrorMessage(Messages.HelpContentPreferencePage_error_port); + setValid(false); + return; + } + } + } + // no errors + setErrorMessage(null); + setValid(true); + } +} diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/BrowsersPreferencePage.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/HelpPreferencePage.java index 213a5b200..c97fb02d1 100644 --- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/BrowsersPreferencePage.java +++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/HelpPreferencePage.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.help.ui.internal.browser; +package org.eclipse.help.ui.internal.preferences; import java.util.Iterator; @@ -40,7 +40,7 @@ import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; /** * Preference page for selecting default web browser. */ -public class BrowsersPreferencePage extends PreferencePage implements +public class HelpPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { private Button alwaysExternal; @@ -70,7 +70,7 @@ public class BrowsersPreferencePage extends PreferencePage implements */ protected Control createContents(Composite parent) { PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, - IHelpUIConstants.PREF_PAGE_BROWSERS); + IHelpUIConstants.PREF_PAGE_HELP); Composite mainComposite = new Composite(parent, SWT.NONE); GridData data = new GridData(); data.verticalAlignment = GridData.FILL; @@ -105,7 +105,7 @@ public class BrowsersPreferencePage extends PreferencePage implements if (node != null) { PreferenceLinkArea linkArea = new PreferenceLinkArea(parent, SWT.WRAP, WBROWSER_PAGE_ID, - Messages.BrowsersPreferencePage_message, + Messages.HelpPreferencePage_message, (IWorkbenchPreferenceContainer) getContainer(), null); GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); @@ -120,17 +120,17 @@ public class BrowsersPreferencePage extends PreferencePage implements layout.numColumns = 2; group.setLayout(layout); group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - group.setText(Messages.BrowsersPreferencePage_openModeGroup); + group.setText(Messages.HelpPreferencePage_openModeGroup); Label whelpDescription = new Label(group, SWT.NONE); - whelpDescription.setText(Messages.BrowsersPreferencePage_wlabel); + whelpDescription.setText(Messages.HelpPreferencePage_wlabel); whelpDescription.setLayoutData(createLabelData()); composite = createRadioComposite(group); whelpAsViewButton = new Button(composite, SWT.RADIO); - whelpAsViewButton.setText(Messages.BrowsersPreferencePage_view); + whelpAsViewButton.setText(Messages.HelpPreferencePage_view); whelpAsViewButton.setLayoutData(createIndentData()); whelpAsInfopopButton = new Button(composite, SWT.RADIO); - whelpAsInfopopButton.setText(Messages.BrowsersPreferencePage_winfopop); + whelpAsInfopopButton.setText(Messages.HelpPreferencePage_winfopop); whelpAsInfopopButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); boolean winfopop = HelpBasePlugin.getDefault().getPluginPreferences() .getBoolean(IHelpBaseConstants.P_KEY_WINDOW_INFOPOP); @@ -138,14 +138,14 @@ public class BrowsersPreferencePage extends PreferencePage implements whelpAsInfopopButton.setSelection(winfopop); Label dhelpDescription = new Label(group, SWT.NONE); - dhelpDescription.setText(Messages.BrowsersPreferencePage_dlabel); + dhelpDescription.setText(Messages.HelpPreferencePage_dlabel); dhelpDescription.setLayoutData(createLabelData()); composite = createRadioComposite(group); dhelpAsTrayButton = new Button(composite, SWT.RADIO); - dhelpAsTrayButton.setText(Messages.BrowsersPreferencePage_tray); + dhelpAsTrayButton.setText(Messages.HelpPreferencePage_tray); dhelpAsTrayButton.setLayoutData(createIndentData()); dhelpAsInfopopButton = new Button(composite, SWT.RADIO); - dhelpAsInfopopButton.setText(Messages.BrowsersPreferencePage_dinfopop); + dhelpAsInfopopButton.setText(Messages.HelpPreferencePage_dinfopop); dhelpAsInfopopButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); boolean dinfopop = HelpBasePlugin.getDefault().getPluginPreferences() .getBoolean(IHelpBaseConstants.P_KEY_DIALOG_INFOPOP); @@ -155,16 +155,16 @@ public class BrowsersPreferencePage extends PreferencePage implements if (PlatformUI.getWorkbench().getBrowserSupport() .isInternalWebBrowserAvailable()) { Label ohelpDescription = new Label(group, SWT.NONE); - ohelpDescription.setText(Messages.BrowsersPreferencePage_olabel); + ohelpDescription.setText(Messages.HelpPreferencePage_olabel); ohelpDescription.setLayoutData(createLabelData()); composite = createRadioComposite(group); openInPlaceButton = new Button(composite, SWT.RADIO); openInPlaceButton - .setText(Messages.BrowsersPreferencePage_openInPlace); + .setText(Messages.HelpPreferencePage_openInPlace); openInPlaceButton.setLayoutData(createIndentData()); openInEditorButton = new Button(composite, SWT.RADIO); openInEditorButton - .setText(Messages.BrowsersPreferencePage_openInEditor); + .setText(Messages.HelpPreferencePage_openInEditor); openInEditorButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); boolean openInBrowser = HelpBasePlugin.getDefault() .getPluginPreferences().getBoolean( @@ -198,15 +198,15 @@ public class BrowsersPreferencePage extends PreferencePage implements private void createSearchArea(Composite parent) { Group searchGroup = new Group(parent, SWT.NONE); - searchGroup.setText(Messages.BrowsersPreferencePage_search); + searchGroup.setText(Messages.HelpPreferencePage_search); searchGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); searchGroup.setLayout(new GridLayout()); showPotentialHitsButton = new Button(searchGroup, SWT.RADIO); - showPotentialHitsButton.setText(Messages.BrowsersPreferencePage_searchPotentialHits); + showPotentialHitsButton.setText(Messages.HelpPreferencePage_searchPotentialHits); showActualHitsButton = new Button(searchGroup, SWT.RADIO); - showActualHitsButton.setText(Messages.BrowsersPreferencePage_searchActualHits); + showActualHitsButton.setText(Messages.HelpPreferencePage_searchActualHits); boolean showPotentialHits = HelpBasePlugin.getDefault().getPluginPreferences() .getBoolean(IHelpBaseConstants.P_KEY_SHOW_POTENTIAL_HITS); |