Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Merks2015-06-07 11:17:48 +0000
committerEd Merks2015-06-07 11:17:48 +0000
commit6cd2ef6504431b9020f1b8caa71c69474f38ba57 (patch)
tree470bd962c32a5b3b4ecc11b55e18cc57ac1dfa28
parent6057c2dbe56a9c9ff8f3576155ad29e8a8ac8905 (diff)
downloadorg.eclipse.oomph-6cd2ef6504431b9020f1b8caa71c69474f38ba57.tar.gz
org.eclipse.oomph-6cd2ef6504431b9020f1b8caa71c69474f38ba57.tar.xz
org.eclipse.oomph-6cd2ef6504431b9020f1b8caa71c69474f38ba57.zip
[468880] eclipse-installer shows an unfriendly error when the Browser
widget is not available https://bugs.eclipse.org/bugs/show_bug.cgi?id=468880
-rw-r--r--plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocConfirmationPage.html2
-rw-r--r--plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocImportWizard.html2
-rw-r--r--plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocInstallWizard.html2
-rw-r--r--plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocProductPage.html2
-rw-r--r--plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocProgressPage.html2
-rw-r--r--plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocProjectPage.html2
-rw-r--r--plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocUpdateWizard.html2
-rw-r--r--plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocVariablePage.html2
-rw-r--r--plugins/org.eclipse.oomph.setup.editor/src/org/eclipse/oomph/setup/presentation/AbstractTableAction.java28
-rw-r--r--plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleProductPage.java31
-rw-r--r--plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleVariablePage.java4
-rw-r--r--plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/ProductPage.java98
-rw-r--r--plugins/org.eclipse.oomph.ui/src/org/eclipse/oomph/ui/HelpSupport.java77
-rw-r--r--plugins/org.eclipse.oomph.ui/src/org/eclipse/oomph/ui/UIUtil.java30
14 files changed, 206 insertions, 78 deletions
diff --git a/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocConfirmationPage.html b/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocConfirmationPage.html
index dab0bc3c7..aa60c584f 100644
--- a/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocConfirmationPage.html
+++ b/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocConfirmationPage.html
@@ -82,7 +82,7 @@ function maximize(id)
<br>
-<div class="box" style="display: inline-block"><img src="..\..\..\images\trees\S6iPPxM28shdYu396Wlp4WERVb4=.png"/></div>
+<div class="box" style="display: inline-block"><img src="../../../images/trees/S6iPPxM28shdYu396Wlp4WERVb4=.png"/></div>
<p>
The page has the following controls:
diff --git a/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocImportWizard.html b/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocImportWizard.html
index 7ce26d993..dd43c344b 100644
--- a/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocImportWizard.html
+++ b/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocImportWizard.html
@@ -81,7 +81,7 @@ function maximize(id)
updates to the project <a href="../../concepts/DocScope.html#DocStream" title="Chapter in Oomph Setup Documentation">streams</a> included to the automated installation and provisioning process.
-<div style="display: inline-block"><img src="..\..\..\images\trees\qoZIZ_J7CLZc0oBKAAvGUEiUlfE=.png"/></div>
+<div style="display: inline-block"><img src="../../../images/trees/qoZIZ_J7CLZc0oBKAAvGUEiUlfE=.png"/></div>
<p>
diff --git a/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocInstallWizard.html b/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocInstallWizard.html
index 49be23469..e365b1e62 100644
--- a/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocInstallWizard.html
+++ b/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocInstallWizard.html
@@ -80,7 +80,7 @@ function maximize(id)
The install wizard is the basis for Oomph's bootstrap-<a href="../../concepts/DocTask.html#DocTrigger" title="Chapter in Oomph Setup Documentation">triggered</a>, automated installation and provisioning process.
-<div style="display: inline-block"><img src="..\..\..\images\trees\30xrELXA4PEQ6rtR5ibuOtGByiI=.png"/></div>
+<div style="display: inline-block"><img src="../../../images/trees/30xrELXA4PEQ6rtR5ibuOtGByiI=.png"/></div>
</p>
<p>
diff --git a/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocProductPage.html b/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocProductPage.html
index 95ee24faf..5efc86aea 100644
--- a/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocProductPage.html
+++ b/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocProductPage.html
@@ -83,7 +83,7 @@ function maximize(id)
The product page is used exclusively by the <a href="DocInstallWizard.html" title="Article in Oomph Setup Documentation">installation wizard</a>.
-<div class="box" style="display: inline-block"><img src="..\..\..\images\trees\dkFZXhn3yqNbmtvRldiU-a-0VZI=.png"/></div>
+<div class="box" style="display: inline-block"><img src="../../../images/trees/dkFZXhn3yqNbmtvRldiU-a-0VZI=.png"/></div>
<p>
The page contains the following controls:
diff --git a/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocProgressPage.html b/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocProgressPage.html
index 4e7fa1d48..563ac6173 100644
--- a/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocProgressPage.html
+++ b/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocProgressPage.html
@@ -80,7 +80,7 @@ function maximize(id)
The primary purpose of the progress page is to manage and monitor the tasks while they are <a href="../../concepts/DocTaskExecution.html" title="Article in Oomph Setup Documentation">performing</a>.
-<div class="box" style="display: inline-block"><img src="..\..\..\images\trees\To_psxrMENeKwy_B5oEq4IuD3n4=.png"/></div>
+<div class="box" style="display: inline-block"><img src="../../../images/trees/To_psxrMENeKwy_B5oEq4IuD3n4=.png"/></div>
<p>
The page contains the following controls:
diff --git a/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocProjectPage.html b/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocProjectPage.html
index 50f03d7de..bf9adf4b5 100644
--- a/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocProjectPage.html
+++ b/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocProjectPage.html
@@ -81,7 +81,7 @@ function maximize(id)
with one or more specific <a href="../../concepts/DocScope.html#DocStream" title="Chapter in Oomph Setup Documentation">project streams</a>.
-<div class="box" style="display: inline-block"><img src="..\..\..\images\trees\i4m5a6AaQ_-_z_ela4-zf7XZgLU=.png"/></div>
+<div class="box" style="display: inline-block"><img src="../../../images/trees/i4m5a6AaQ_-_z_ela4-zf7XZgLU=.png"/></div>
<p>
The page contains the following controls:
diff --git a/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocUpdateWizard.html b/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocUpdateWizard.html
index 19f184479..77fd747c0 100644
--- a/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocUpdateWizard.html
+++ b/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocUpdateWizard.html
@@ -81,7 +81,7 @@ function maximize(id)
<br/>
-<div style="display: inline-block"><img src="..\..\..\images\trees\K62OQIjOSls_qBdWGo1heoyzSsA=.png"/></div>
+<div style="display: inline-block"><img src="../../../images/trees/K62OQIjOSls_qBdWGo1heoyzSsA=.png"/></div>
</p>
<p>
diff --git a/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocVariablePage.html b/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocVariablePage.html
index adc2f5736..a0d2a7d92 100644
--- a/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocVariablePage.html
+++ b/plugins/org.eclipse.oomph.setup.doc/html/user/wizard/DocVariablePage.html
@@ -86,7 +86,7 @@ function maximize(id)
Information related to those variables is displayed on this page in a three column format:
-<div class="box" style="display: inline-block"><img src="..\..\..\images\trees\ZhO_6FbqmsbeHn29eT4-F-buauY=.png"/></div>
+<div class="box" style="display: inline-block"><img src="../../../images/trees/ZhO_6FbqmsbeHn29eT4-F-buauY=.png"/></div>
<p>
The page has the following controls:
diff --git a/plugins/org.eclipse.oomph.setup.editor/src/org/eclipse/oomph/setup/presentation/AbstractTableAction.java b/plugins/org.eclipse.oomph.setup.editor/src/org/eclipse/oomph/setup/presentation/AbstractTableAction.java
index 1a27cc3ee..6397e07cb 100644
--- a/plugins/org.eclipse.oomph.setup.editor/src/org/eclipse/oomph/setup/presentation/AbstractTableAction.java
+++ b/plugins/org.eclipse.oomph.setup.editor/src/org/eclipse/oomph/setup/presentation/AbstractTableAction.java
@@ -10,6 +10,11 @@
*/
package org.eclipse.oomph.setup.presentation;
+import org.eclipse.oomph.ui.ErrorDialog;
+import org.eclipse.oomph.ui.UIUtil;
+import org.eclipse.oomph.util.IOUtil;
+import org.eclipse.oomph.util.OS;
+
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
@@ -20,6 +25,8 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPart;
+import java.io.File;
+
/**
* @author Eike Stepper
*/
@@ -40,8 +47,25 @@ public abstract class AbstractTableAction extends Action
@Override
public void run()
{
- Dialog dialog = new CommandTableDialog(part.getSite().getShell());
- dialog.open();
+ if (UIUtil.isBrowserAvailable())
+ {
+ Dialog dialog = new CommandTableDialog(part.getSite().getShell());
+ dialog.open();
+ }
+ else
+ {
+ try
+ {
+ String html = renderHTML();
+ File tempFile = File.createTempFile("table", ".html");
+ IOUtil.writeUTF8(tempFile, html);
+ OS.INSTANCE.openSystemBrowser(tempFile.toURI().toString());
+ }
+ catch (Exception ex)
+ {
+ ErrorDialog.open(ex);
+ }
+ }
}
protected abstract String renderHTML();
diff --git a/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleProductPage.java b/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleProductPage.java
index 86197a9ec..abd922304 100644
--- a/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleProductPage.java
+++ b/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleProductPage.java
@@ -67,11 +67,6 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.ToolBar;
-import javax.swing.text.html.HTMLEditorKit;
-import javax.swing.text.html.parser.ParserDelegator;
-
-import java.io.IOException;
-import java.io.StringReader;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
@@ -136,7 +131,7 @@ public class SimpleProductPage extends SimpleInstallerPage implements FilterHand
indexLoader = new SpriteIndexLoader(stackComposite);
- if ("browser".equals(PropertiesUtil.getProperty("oomph.product.list")))
+ if (UIUtil.isBrowserAvailable() && "browser".equals(PropertiesUtil.getProperty("oomph.product.list")))
{
productList = new BrowserProductList(this, stackComposite, catalogSelector);
}
@@ -700,7 +695,7 @@ public class SimpleProductPage extends SimpleInstallerPage implements FilterHand
private static String shorten(GC gc, int width, int lines, String html)
{
- String plain = StringUtil.isEmpty(html) ? "No description available." : stripHTML(html);
+ String plain = StringUtil.isEmpty(html) ? "No description available." : UIUtil.stripHTML(html);
StringBuilder builder = new StringBuilder();
int lineWidth = 0;
@@ -730,28 +725,6 @@ public class SimpleProductPage extends SimpleInstallerPage implements FilterHand
return builder.toString();
}
- private static String stripHTML(String html)
- {
- try
- {
- final StringBuilder builder = new StringBuilder();
- new ParserDelegator().parse(new StringReader(html), new HTMLEditorKit.ParserCallback()
- {
- @Override
- public void handleText(char[] text, int pos)
- {
- builder.append(text);
- }
- }, Boolean.TRUE);
-
- return builder.toString();
- }
- catch (IOException ex)
- {
- return html;
- }
- }
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleVariablePage.java b/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleVariablePage.java
index dae589f8a..7b03e1e55 100644
--- a/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleVariablePage.java
+++ b/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleVariablePage.java
@@ -222,7 +222,7 @@ public class SimpleVariablePage extends SimpleInstallerPage
detailArea.setLayoutData(browserLayoutData);
detailArea.setLayout(new FillLayout());
- try
+ if (UIUtil.isBrowserAvailable())
{
detailBrowser = new Browser(detailArea, SWT.NO_SCROLL);
detailBrowser.addLocationListener(new LocationAdapter()
@@ -239,7 +239,7 @@ public class SimpleVariablePage extends SimpleInstallerPage
}
});
}
- catch (Throwable ex)
+ else
{
detailBrowser = null;
detailComposite = new ProductComposite(detailArea, null, null);
diff --git a/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/ProductPage.java b/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/ProductPage.java
index df49a1b77..059f19fa6 100644
--- a/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/ProductPage.java
+++ b/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/ProductPage.java
@@ -110,15 +110,22 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.LocationAdapter;
import org.eclipse.swt.browser.LocationEvent;
+import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.dnd.URLTransfer;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -129,6 +136,7 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.Tree;
@@ -166,6 +174,8 @@ public class ProductPage extends SetupWizardPage
private Browser descriptionBrowser;
+ private DescriptionViewer descriptionViewer;
+
private Label versionLabel;
private ComboViewer versionComboViewer;
@@ -641,8 +651,7 @@ public class ProductPage extends SetupWizardPage
Composite descriptionComposite = new Composite(sashForm, SWT.BORDER);
descriptionComposite.setLayout(new FillLayout());
-
- try
+ if (UIUtil.isBrowserAvailable())
{
descriptionBrowser = new Browser(descriptionComposite, SWT.NONE);
descriptionBrowser.addLocationListener(new LocationAdapter()
@@ -659,15 +668,16 @@ public class ProductPage extends SetupWizardPage
});
AccessUtil.setKey(descriptionBrowser, "description");
- sashForm.setWeights(new int[] { 14, 5 });
}
- catch (Exception ex)
+ else
{
- descriptionComposite.dispose();
- descriptionBrowser = null;
- sashForm.setWeights(new int[] { 1 });
+ descriptionComposite.setForeground(productTree.getForeground());
+ descriptionComposite.setBackground(productTree.getBackground());
+ descriptionViewer = new DescriptionViewer(descriptionComposite, productTree.getFont());
}
+ sashForm.setWeights(new int[] { 14, 5 });
+
final CatalogSelection selection = catalogManager.getSelection();
productViewer.setInput(selection);
@@ -820,8 +830,15 @@ public class ProductPage extends SetupWizardPage
if (descriptionBrowser != null)
{
+ String html = safe(productSelected ? getDescriptionHTML(product) : null);
descriptionBrowser.setEnabled(productSelected);
- descriptionBrowser.setText(safe(productSelected ? getDescriptionHTML(product) : null));
+ descriptionBrowser.setText(html);
+ }
+ else
+ {
+ String html = safe(productSelected ? product.getDescription() : null);
+ String plain = StringUtil.isEmpty(html) ? "No description available." : UIUtil.stripHTML(html);
+ descriptionViewer.update(getImage(product), SetupCoreUtil.getLabel(product), plain);
}
versionLabel.setEnabled(productSelected);
@@ -1241,6 +1258,71 @@ public class ProductPage extends SetupWizardPage
}
/**
+ * @author Ed Merks
+ */
+ private static class DescriptionViewer
+ {
+ private ScrolledComposite scrolledComposite;
+
+ private Composite descriptionComposite;
+
+ private CLabel descriptionLabel;
+
+ private Text descriptionText;
+
+ private ControlAdapter resizeListener;
+
+ public DescriptionViewer(Composite container, Font font)
+ {
+ Color foreground = container.getForeground();
+ Color background = container.getBackground();
+
+ scrolledComposite = new ScrolledComposite(container, SWT.VERTICAL);
+ scrolledComposite.setExpandHorizontal(true);
+ scrolledComposite.setExpandVertical(true);
+
+ resizeListener = new ControlAdapter()
+ {
+ @Override
+ public void controlResized(ControlEvent e)
+ {
+ Point size = descriptionComposite.computeSize(scrolledComposite.getClientArea().width, SWT.DEFAULT);
+ scrolledComposite.setMinSize(size);
+ }
+ };
+ scrolledComposite.addControlListener(resizeListener);
+
+ descriptionComposite = new Composite(scrolledComposite, SWT.NONE);
+ descriptionComposite.setLayout(new GridLayout());
+ descriptionComposite.setForeground(foreground);
+ descriptionComposite.setBackground(background);
+ scrolledComposite.setContent(descriptionComposite);
+
+ descriptionLabel = new CLabel(descriptionComposite, SWT.NONE);
+ descriptionLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ descriptionLabel.setForeground(foreground);
+ descriptionLabel.setBackground(background);
+ descriptionLabel.setFont(SetupUIPlugin.getFont(font, URI.createURI("font:///+2/bold")));
+
+ Label separator = new Label(descriptionComposite, SWT.HORIZONTAL | SWT.SEPARATOR);
+ separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ descriptionText = new Text(descriptionComposite, SWT.READ_ONLY | SWT.WRAP);
+ descriptionText.setLayoutData(new GridData(GridData.FILL_BOTH));
+ descriptionText.setForeground(foreground);
+ descriptionText.setBackground(background);
+ }
+
+ public void update(Image image, String title, String body)
+ {
+ descriptionLabel.setImage(image);
+ descriptionLabel.setText(title);
+ descriptionText.setText(body);
+ resizeListener.controlResized(null);
+ }
+ }
+
+ /**
* @author Eike Stepper
*/
private static final class ItemProviderAdapterFactory extends SetupItemProviderAdapterFactory implements SetupPackage.Literals
diff --git a/plugins/org.eclipse.oomph.ui/src/org/eclipse/oomph/ui/HelpSupport.java b/plugins/org.eclipse.oomph.ui/src/org/eclipse/oomph/ui/HelpSupport.java
index 786aed0f6..dd0397af2 100644
--- a/plugins/org.eclipse.oomph.ui/src/org/eclipse/oomph/ui/HelpSupport.java
+++ b/plugins/org.eclipse.oomph.ui/src/org/eclipse/oomph/ui/HelpSupport.java
@@ -12,6 +12,7 @@ package org.eclipse.oomph.ui;
import org.eclipse.oomph.internal.ui.UIPlugin;
import org.eclipse.oomph.internal.util.HTTPServer;
+import org.eclipse.oomph.util.OS;
import org.eclipse.jface.dialogs.DialogTray;
import org.eclipse.jface.dialogs.TitleAreaDialog;
@@ -92,37 +93,49 @@ public class HelpSupport
{
public void helpRequested(HelpEvent e)
{
- if (dialog.getTray() != null)
+ if (UIUtil.isBrowserAvailable())
{
- dialog.closeTray();
- helpButton.setSelection(false);
- return;
- }
+ if (dialog.getTray() != null)
+ {
+ dialog.closeTray();
+ helpButton.setSelection(false);
+ return;
+ }
- DialogTray tray = new DialogTray()
- {
- @Override
- protected Control createContents(Composite parent)
+ DialogTray tray = new DialogTray()
{
- helpBrowser = new Browser(parent, SWT.NONE);
- helpBrowser.setSize(500, 800);
- helpBrowser.addDisposeListener(new DisposeListener()
+ @Override
+ protected Control createContents(Composite parent)
{
- public void widgetDisposed(DisposeEvent e)
+ helpBrowser = new Browser(parent, SWT.NONE);
+ helpBrowser.setSize(500, 800);
+ helpBrowser.addDisposeListener(new DisposeListener()
{
- helpBrowser = null;
- redrawCalloutControls();
- }
- });
+ public void widgetDisposed(DisposeEvent e)
+ {
+ helpBrowser = null;
+ redrawCalloutControls();
+ }
+ });
+
+ updateHelp();
+ return helpBrowser;
+ }
+ };
- updateHelp();
- return helpBrowser;
- }
- };
+ dialog.openTray(tray);
+ helpButton.setSelection(true);
+ }
+ else
+ {
+ helpButton.setSelection(false);
- dialog.openTray(tray);
- helpButton.setSelection(true);
- redrawCalloutControls();
+ String helpPath = getHelpPath();
+ if (helpPath != null)
+ {
+ OS.INSTANCE.openSystemBrowser(getHelpURL(helpPath));
+ }
+ }
}
});
@@ -136,15 +149,23 @@ public class HelpSupport
public final void updateHelp()
{
+ String helpPath = getHelpPath();
+ if (helpPath != null)
+ {
+ setHelpPath(helpPath);
+ }
+ }
+
+ private final String getHelpPath()
+ {
if (dialog instanceof HelpProvider)
{
HelpProvider helpProvider = (HelpProvider)dialog;
String helpPath = helpProvider.getHelpPath();
- if (helpPath != null)
- {
- setHelpPath(helpPath);
- }
+ return helpPath;
}
+
+ return null;
}
public final void addHelpCallout(final Control control, final int number)
diff --git a/plugins/org.eclipse.oomph.ui/src/org/eclipse/oomph/ui/UIUtil.java b/plugins/org.eclipse.oomph.ui/src/org/eclipse/oomph/ui/UIUtil.java
index c70ac0be3..c093c9e0a 100644
--- a/plugins/org.eclipse.oomph.ui/src/org/eclipse/oomph/ui/UIUtil.java
+++ b/plugins/org.eclipse.oomph.ui/src/org/eclipse/oomph/ui/UIUtil.java
@@ -20,6 +20,7 @@ import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTError;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.custom.CCombo;
@@ -43,6 +44,11 @@ import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
+import javax.swing.text.html.HTMLEditorKit;
+import javax.swing.text.html.parser.ParserDelegator;
+
+import java.io.IOException;
+import java.io.StringReader;
import java.lang.reflect.InvocationTargetException;
/**
@@ -174,7 +180,7 @@ public final class UIUtil
new Browser(shell, SWT.NONE);
browserAvailable = true;
}
- catch (Exception ex)
+ catch (SWTError ex)
{
browserAvailable = false;
}
@@ -709,4 +715,26 @@ public final class UIUtil
{
}
}
+
+ public static String stripHTML(String html)
+ {
+ try
+ {
+ final StringBuilder builder = new StringBuilder();
+ new ParserDelegator().parse(new StringReader(html), new HTMLEditorKit.ParserCallback()
+ {
+ @Override
+ public void handleText(char[] text, int pos)
+ {
+ builder.append(text);
+ }
+ }, Boolean.TRUE);
+
+ return builder.toString();
+ }
+ catch (IOException ex)
+ {
+ return html;
+ }
+ }
}

Back to the top