Author: mareshkau
Date: 2010-12-13 09:00:33 -0500 (Mon, 13 Dec 2010)
New Revision: 27410
Added:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/browser/
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/browser/CSSBrowser.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSPreview.java
Log:
https://issues.jboss.org/browse/JBIDE-7741
Added:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/browser/CSSBrowser.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/browser/CSSBrowser.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/browser/CSSBrowser.java 2010-12-13
14:00:33 UTC (rev 27410)
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.css.browser;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTError;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.jst.css.CSSPlugin;
+
+/**
+ * @author mareshkau
+ *
+ */
+public class CSSBrowser extends Composite {
+
+ private Browser browser;
+
+ public Browser getBrowser() {
+ return browser;
+ }
+ /**
+ * If in system not installed xulrunner, than
+ * browser will be null
+ * @param browser, can be a null
+ */
+ private CSSBrowser(Composite parent, int style) {
+ super(parent, style);
+ }
+ /**
+ * Factory method which creates browser instance
+ * @return
+ */
+ public static CSSBrowser createCSSBrowser(Composite parent, int style){
+ CSSBrowser cssBrowser = new CSSBrowser(parent,style);
+ cssBrowser.setLayout(new GridLayout());
+ Browser browser=null;
+ try {
+ browser = new Browser(cssBrowser, SWT.BORDER | SWT.MOZILLA);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ browser.setLayoutData(gridData);
+ browser.pack();
+ } catch(SWTError er){
+ CSSPlugin.getDefault().logError(er);
+ }
+ cssBrowser.setBrowser(browser);
+ return cssBrowser;
+ }
+
+ public void setBrowser(Browser browser) {
+ this.browser = browser;
+ }
+ public void setLayoutData(GridData layoutData) {
+ super.setLayoutData(layoutData);
+ }
+ public boolean setFocus() {
+ return getBrowser().setFocus();
+ }
+ public void setText(String generateBrowserPage) {
+ getBrowser().setText(generateBrowserPage);
+ }
+ public void setEnabled(boolean isEnabled) {
+ getBrowser().setEnabled(isEnabled);
+ }
+ public void addMouseListener(MouseAdapter mouseAdapter) {
+ getBrowser().addMouseListener(mouseAdapter);
+ }
+}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSPreview.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSPreview.java 2010-12-13
13:54:07 UTC (rev 27409)
+++
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSPreview.java 2010-12-13
14:00:33 UTC (rev 27410)
@@ -18,7 +18,6 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
@@ -32,6 +31,7 @@
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.ViewPart;
+import org.jboss.tools.jst.css.browser.CSSBrowser;
import org.jboss.tools.jst.css.common.CSSStyleListener;
import org.jboss.tools.jst.css.common.ICSSViewListner;
import org.jboss.tools.jst.css.common.StyleContainer;
@@ -44,7 +44,7 @@
*/
public class CSSPreview extends ViewPart implements ICSSViewListner {
- private Browser browser;
+ private CSSBrowser browser;
private Text previewText;
@@ -83,11 +83,11 @@
true);
previewComposite.setLayoutData(gridData);
- browser = new Browser(previewComposite, SWT.BORDER | SWT.MOZILLA);
+ browser = CSSBrowser.createCSSBrowser(previewComposite, SWT.BORDER | SWT.MOZILLA);
browser.setLayoutData(gridData);
browser.addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(MouseEvent e) {
- if (e.widget == browser) {
+ if (e.widget == browser.getBrowser()) {
browser.setEnabled(false);
previewComposite.setMaximizedControl(previewText);
previewText.setFocus();