Skip to content

Commit

Permalink
Merge pull request eclipse-color-theme#146 from jeckhart/fix-browser-…
Browse files Browse the repository at this point in the history
…problem-rebased

Fix browser problem rebased
  • Loading branch information
fhd committed Nov 6, 2013
2 parents ac073a7 + 657eea1 commit 90c1e1c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
4 changes: 3 additions & 1 deletion com.github.eclipsecolortheme/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ Bundle-SymbolicName: com.github.eclipsecolortheme;singleton:=true
Bundle-Version: 0.13.0.qualifier
Bundle-Activator: com.github.eclipsecolortheme.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime
org.eclipse.core.runtime,
org.eclipse.e4.ui.workbench.addons.swt,
org.eclipse.ui.forms
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: com.github.eclipsecolortheme,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
Expand All @@ -31,7 +32,6 @@
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.ToolTip;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbench;
Expand Down Expand Up @@ -98,9 +98,11 @@ protected Control createContents(Composite parent) {
themeDetails.setLayout(themeDetailsLayout);
gridData = new GridData(GridData.FILL_BOTH);
gridData.heightHint = 306;
browser = new Browser(themeDetails, SWT.BORDER);
browser.setLayoutData(gridData);
browser.setText("<html><body></body></html>");
Browser browser = getBrowser();
if (browser != null) {
browser.setLayoutData(gridData);
browser.setText("<html><body></body></html>");
}
authorLabel = new Label(themeDetails, SWT.NONE);
GridDataFactory.swtDefaults().grab(true, false).applyTo(authorLabel);
websiteLink = new Link(themeDetails, SWT.NONE);
Expand Down Expand Up @@ -132,6 +134,24 @@ public void handleEvent(Event event) {
return container;
}

private Browser getBrowser() {
if (browser != null)
return browser;

try {
browser = new Browser(themeDetails, SWT.BORDER | SWT.NO_SCROLL);
} catch (SWTError e) {
try {
browser = new Browser(themeDetails, SWT.BORDER | SWT.WEBKIT);
} catch (SWTError e1) {
e.printStackTrace();
e1.printStackTrace();
}
}

return browser;
}

private void fillThemeSelectionList() {
Set<ColorTheme> themes = colorThemeManager.getThemes();
java.util.List<String> themeNames = new LinkedList<String>();
Expand Down Expand Up @@ -168,7 +188,9 @@ private void updateDetails(ColorTheme theme) {
websiteLink.setVisible(true);
}
String id = theme.getId();
browser.setUrl(
Browser browser = getBrowser();
if (browser != null)
browser.setUrl(
"http://www.eclipsecolorthemes.org/static/themes/java/"
+ id + ".html");
themeDetails.setVisible(true);
Expand Down

0 comments on commit 90c1e1c

Please sign in to comment.