--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ConnectionUIUtils.java Fri Sep 17 10:06:16 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ConnectionUIUtils.java Fri Sep 17 10:34:07 2010 -0500
@@ -20,16 +20,15 @@
import java.util.Collection;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.JFaceColors;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService;
-import com.nokia.carbide.remoteconnections.interfaces.IConnection;
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus;
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus.EStatus;
+import com.nokia.carbide.remoteconnections.interfaces.IConnection;
import com.nokia.carbide.remoteconnections.internal.api.IConnection2;
import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatus;
import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatus.EConnectionStatus;
@@ -77,7 +76,6 @@
public static final Color COLOR_GREEN = new Color(Display.getDefault(), 0, 128, 0);
public static final Color COLOR_ELECTRIC = new Color(Display.getDefault(), 0, 0, 255);
public static final Color COLOR_GREY = new Color(Display.getDefault(), 96, 96, 96);
- public static final Color COLOR_HYPERLINK = JFaceColors.getHyperlinkText(Display.getDefault());
/**
* Get the image representing the connection status.
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionSettingsPage.java Fri Sep 17 10:06:16 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionSettingsPage.java Fri Sep 17 10:34:07 2010 -0500
@@ -48,6 +48,7 @@
import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.TreeNode;
import org.eclipse.jface.viewers.TreeNodeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
@@ -111,6 +112,8 @@
import com.nokia.cpp.internal.api.utils.core.ObjectUtils;
import com.nokia.cpp.internal.api.utils.core.Pair;
import com.nokia.cpp.internal.api.utils.ui.BrowseDialogUtils;
+import com.nokia.cpp.internal.api.utils.ui.LinkParser;
+import com.nokia.cpp.internal.api.utils.ui.LinkParser.Element;
public class ConnectionSettingsPage extends WizardPage implements ISettingsChangedListener {
@@ -802,8 +805,15 @@
public void statusChanged(final IStatus status) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
- if (!statusText.isDisposed())
- statusText.setText(status.getLongDescription());
+ if (!statusText.isDisposed()) {
+ String longDescription = status.getLongDescription();
+ if (longDescription != null) {
+ List<Element> elements = LinkParser.parseText(longDescription);
+ StyledString styledString = LinkParser.getStyledString(elements);
+ longDescription = styledString.getString();
+ }
+ statusText.setText(longDescription);
+ }
if (status.getEStatus().equals(EStatus.UP))
resetServiceTesting(false);
}
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/view/DescriptionLabelProvider.java Fri Sep 17 10:06:16 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/view/DescriptionLabelProvider.java Fri Sep 17 10:34:07 2010 -0500
@@ -2,15 +2,11 @@
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.ArrayList;
import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.StyledCellLabelProvider;
import org.eclipse.jface.viewers.StyledString;
-import org.eclipse.jface.viewers.StyledString.Styler;
import org.eclipse.jface.viewers.TreeNode;
import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.jface.viewers.ViewerCell;
@@ -19,7 +15,6 @@
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.TextStyle;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
@@ -36,41 +31,16 @@
import com.nokia.carbide.remoteconnections.internal.ui.ConnectionUIUtils;
import com.nokia.carbide.remoteconnections.settings.ui.SettingsWizard;
import com.nokia.cpp.internal.api.utils.core.TextUtils;
+import com.nokia.cpp.internal.api.utils.ui.LinkParser;
import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils;
+import com.nokia.cpp.internal.api.utils.ui.LinkParser.Element;
+import com.nokia.cpp.internal.api.utils.ui.LinkParser.LinkElement;
public class DescriptionLabelProvider extends StyledCellLabelProvider {
- private class Element {
- private String text;
-
- public Element(String text) {
- this.text = text;
- }
-
- public String getText() {
- return text;
- }
- }
-
- private class LinkElement extends Element {
- private String href;
-
- public LinkElement(String href, String text) {
- super(text);
- this.href = href;
- }
-
- public String getHref() {
- return href;
- }
- }
-
- private static final Pattern HREF_PATTERN =
- Pattern.compile("<a href=\"([^\"]*)\">(.*?)</a>", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
private static final String AGENT_INSTALLERS_URL = "about:agentInstallers"; //$NON-NLS-1$
private final ConnectionsView connectionsView;
- private Styler hyperLinkStyler;
private TreeViewerColumn treeViewerColumn;
private Listener mouseListener;
@@ -78,13 +48,6 @@
this.connectionsView = connectionsView;
this.treeViewerColumn = treeViewerColumn;
hookColumn();
- hyperLinkStyler = new Styler() {
- @Override
- public void applyStyles(TextStyle textStyle) {
- textStyle.foreground = ConnectionUIUtils.COLOR_HYPERLINK;
- textStyle.underline = true;
- }
- };
}
private void hookColumn() {
@@ -122,7 +85,7 @@
return null;
TreeItem item = (TreeItem) cell.getItem();
String text = getText(cell.getElement());
- List<Element> elements = parseText(text);
+ List<Element> elements = LinkParser.parseText(text);
if (elements.isEmpty())
return null;
int locMouseX = event.x - item.getTextBounds(ConnectionsView.DESCRIPTION_COLUMN_INDEX).x;
@@ -211,9 +174,9 @@
public void update(ViewerCell cell) {
Object element = cell.getElement();
String text = getText(element);
- List<Element> elements = parseText(text);
+ List<Element> elements = LinkParser.parseText(text);
- StyledString styledString = getStyledString(elements);
+ StyledString styledString = LinkParser.getStyledString(elements);
cell.setText(styledString.toString());
cell.setStyleRanges(styledString.getStyleRanges());
@@ -223,34 +186,6 @@
super.update(cell);
}
- private List<Element> parseText(String text) {
- List<Element> elements = new ArrayList<Element>();
- if (text != null) {
- Matcher m = HREF_PATTERN.matcher(text);
- int start = 0;
- int end;
- while (m.find()) {
- end = m.start();
- if (start <= end)
- elements.add(new Element(text.substring(start, end)));
- elements.add(new LinkElement(m.group(1), m.group(2)));
- start = m.end();
- }
- end = text.length();
- if (start <= end)
- elements.add(new Element(text.substring(start, end)));
- }
- return elements;
- }
-
- private StyledString getStyledString(List<Element> elements) {
- StyledString styledString = new StyledString();
- for (Element element : elements) {
- styledString.append(element.getText(), element instanceof LinkElement ? hyperLinkStyler : null);
- }
- return styledString;
- }
-
private String getText(Object obj) {
TreeNode node = (TreeNode) obj;
Object value = node.getValue();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.cpp.utils.ui/src/com/nokia/cpp/internal/api/utils/ui/LinkParser.java Fri Sep 17 10:34:07 2010 -0500
@@ -0,0 +1,78 @@
+package com.nokia.cpp.internal.api.utils.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.jface.resource.JFaceColors;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.StyledString.Styler;
+import org.eclipse.swt.graphics.TextStyle;
+import org.eclipse.swt.widgets.Display;
+
+public class LinkParser {
+
+ public static class Element {
+ private String text;
+
+ public Element(String text) {
+ this.text = text;
+ }
+
+ public String getText() {
+ return text;
+ }
+ }
+
+ public static class LinkElement extends Element {
+ private String href;
+
+ public LinkElement(String href, String text) {
+ super(text);
+ this.href = href;
+ }
+
+ public String getHref() {
+ return href;
+ }
+ }
+
+ private static final Pattern HREF_PATTERN = Pattern.compile("<a href=\"([^\"]*)\">(.*?)</a>", Pattern.CASE_INSENSITIVE);
+ private static Styler hyperLinkStyler = new Styler() {
+ @Override
+ public void applyStyles(TextStyle textStyle) {
+ textStyle.foreground = JFaceColors.getHyperlinkText(Display.getDefault());
+ textStyle.underline = true;
+ }
+ };
+
+ public static List<Element> parseText(String text) {
+ List<Element> elements = new ArrayList<Element>();
+ if (text != null) {
+ Matcher m = HREF_PATTERN.matcher(text);
+ int start = 0;
+ int end;
+ while (m.find()) {
+ end = m.start();
+ if (start <= end)
+ elements.add(new Element(text.substring(start, end)));
+ elements.add(new LinkElement(m.group(1), m.group(2)));
+ start = m.end();
+ }
+ end = text.length();
+ if (start <= end)
+ elements.add(new Element(text.substring(start, end)));
+ }
+ return elements;
+ }
+
+ public static StyledString getStyledString(List<Element> elements) {
+ StyledString styledString = new StyledString();
+ for (Element element : elements) {
+ styledString.append(element.getText(), element instanceof LinkElement ? hyperLinkStyler : null);
+ }
+ return styledString;
+ }
+
+}
\ No newline at end of file
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceDialog.java Fri Sep 17 10:06:16 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceDialog.java Fri Sep 17 10:34:07 2010 -0500
@@ -38,6 +38,7 @@
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
@@ -59,13 +60,15 @@
import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService;
+import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatusChangedListener;
import com.nokia.carbide.remoteconnections.interfaces.IConnection;
import com.nokia.carbide.remoteconnections.interfaces.IConnectionType;
import com.nokia.carbide.remoteconnections.interfaces.IConnectionTypeProvider;
import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager;
-import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatusChangedListener;
import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionListener;
import com.nokia.carbide.remoteconnections.settings.ui.SettingsWizard;
+import com.nokia.cpp.internal.api.utils.ui.LinkParser;
+import com.nokia.cpp.internal.api.utils.ui.LinkParser.Element;
/**
* This dialog allows in-depth configuration of the connection settings.
@@ -216,6 +219,11 @@
if (!serviceStatus.getEStatus().equals(
com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus.EStatus.UP)) {
String description = serviceStatus.getLongDescription();
+ if (description != null) {
+ List<Element> elements = LinkParser.parseText(description);
+ StyledString styledString = LinkParser.getStyledString(elements);
+ description = styledString.getString();
+ }
status = warning(Messages.getString("ConnectToDeviceDialog.ServiceNotAvailWarning"), //$NON-NLS-1$
description == null ? "" : description); //$NON-NLS-1$
}