Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTod Creasey2005-03-30 21:23:28 +0000
committerTod Creasey2005-03-30 21:23:28 +0000
commit8313b25ea65505671e218bbc8477d3d7fab9c3a0 (patch)
tree8bedcc1a40bba4b585911bc213c5848151e7fb40
parent8e34e22ce27cf48c5828ff0a505ef119b476b683 (diff)
downloadeclipse.platform.ui-8313b25ea65505671e218bbc8477d3d7fab9c3a0.tar.gz
eclipse.platform.ui-8313b25ea65505671e218bbc8477d3d7fab9c3a0.tar.xz
eclipse.platform.ui-8313b25ea65505671e218bbc8477d3d7fab9c3a0.zip
Fix for 89530
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/dialogs/PreferenceLinkArea.java141
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java1
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties1
3 files changed, 80 insertions, 63 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/dialogs/PreferenceLinkArea.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/dialogs/PreferenceLinkArea.java
index a049ef9eb41..4a0dac8f602 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/dialogs/PreferenceLinkArea.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/dialogs/PreferenceLinkArea.java
@@ -15,83 +15,98 @@ import java.util.Iterator;
import org.eclipse.jface.preference.IPreferenceNode;
import org.eclipse.jface.preference.PreferenceManager;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Link;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.WorkbenchMessages;
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
/**
* The PreferenceLinkArea is the link area used to open a specific preference
* page.
+ *
* @since 3.1
*/
public class PreferenceLinkArea extends Object {
-
- private Link pageLink;
- /**
- * Create a new instance of the receiver
- *
- * @param parent
- * the parent Composite
- * @param style
- * the SWT style
- * @param pageId
- * the page id
- * @param message
- * the message to use as text
- * @param pageContainer -
- * The container another page will be opened in.
- * @param pageData -
- * The data to apply to the page.
- */
- public PreferenceLinkArea(Composite parent, int style, final String pageId,
- String message, final IWorkbenchPreferenceContainer pageContainer,
- final Object pageData) {
- pageLink = new Link(parent,style);
- pageLink.addSelectionListener(new SelectionAdapter(){
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- pageContainer.openPage(pageId, pageData);
- }
- });
- IPreferenceNode node = getPreferenceNode(pageId);
- if (node == null) {
- throw new IllegalArgumentException("Node not found");//$NON-NLS-1$
- }
- String result = MessageFormat.format(message, new String[] { node
- .getLabelText() });
- pageLink.setText(result);
-
- }
+ private Link pageLink;
- /**
- * Get the preference node with pageId.
- *
- * @param pageId
- * @return IPreferenceNode
- */
- private IPreferenceNode getPreferenceNode(String pageId) {
- Iterator iterator = PlatformUI.getWorkbench().getPreferenceManager()
- .getElements(PreferenceManager.PRE_ORDER).iterator();
- while (iterator.hasNext()) {
- IPreferenceNode next = (IPreferenceNode) iterator.next();
- if (next.getId().equals(pageId))
- return next;
- }
- return null;
- }
-
- /**
- * Return the control for the receiver.
- * @return Control
- */
- public Control getControl(){
- return pageLink;
- }
+ /**
+ * Create a new instance of the receiver
+ *
+ * @param parent
+ * the parent Composite
+ * @param style
+ * the SWT style
+ * @param pageId
+ * the page id
+ * @param message
+ * the message to use as text. If this message has {0} in
+ * its value it will be bound with the displayed name of
+ * the preference page. This message must be well formed
+ * html if you wish to link to another page.
+ * @param pageContainer -
+ * The container another page will be opened in.
+ * @param pageData -
+ * The data to apply to the page.
+ */
+ public PreferenceLinkArea(Composite parent, int style, final String pageId,
+ String message, final IWorkbenchPreferenceContainer pageContainer,
+ final Object pageData) {
+ pageLink = new Link(parent, style);
+
+ IPreferenceNode node = getPreferenceNode(pageId);
+ String result;
+ if (node == null)
+ result = NLS.bind(
+ WorkbenchMessages.PreferenceNode_NotFound, pageId);
+ else {
+ result = MessageFormat.format(message, new String[] { node
+ .getLabelText() });
+
+ //Only add the selection listener if the node is found
+ pageLink.addSelectionListener(new SelectionAdapter() {
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent e) {
+ pageContainer.openPage(pageId, pageData);
+ }
+ });
+ }
+ pageLink.setText(result);
+
+ }
+
+ /**
+ * Get the preference node with pageId.
+ *
+ * @param pageId
+ * @return IPreferenceNode
+ */
+ private IPreferenceNode getPreferenceNode(String pageId) {
+ Iterator iterator = PlatformUI.getWorkbench().getPreferenceManager()
+ .getElements(PreferenceManager.PRE_ORDER).iterator();
+ while (iterator.hasNext()) {
+ IPreferenceNode next = (IPreferenceNode) iterator.next();
+ if (next.getId().equals(pageId))
+ return next;
+ }
+ return null;
+ }
+
+ /**
+ * Return the control for the receiver.
+ *
+ * @return Control
+ */
+ public Control getControl() {
+ return pageLink;
+ }
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java
index 077c3f4fa09..fbbcf06be53 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java
@@ -342,6 +342,7 @@ public class WorkbenchMessages extends NLS {
// ==============================================================================
public static String PreferenceNode_errorTitle;
public static String PreferenceNode_errorMessage;
+ public static String PreferenceNode_NotFound;
public static String Preference_note;
// --- Import/Export ---
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties
index 9611125663c..aea3aed30dc 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties
@@ -327,6 +327,7 @@ NewProject_title = New Project
# ==============================================================================
PreferenceNode_errorTitle = Preference Page Creation Problems
PreferenceNode_errorMessage = Unable to create the selected preference page.
+PreferenceNode_NotFound = {0} not found
Preference_note = Note:
# --- Import/Export ---

Back to the top