Author: mareshkau
Date: 2010-12-13 11:43:24 -0500 (Mon, 13 Dec 2010)
New Revision: 27413
Added:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/browser/CSSBrowserEmptyImplementation.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/browser/CSSBrowserInterface.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/browser/CSSBrowserMozillaImplementation.java
Modified:
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/view/CSSPreview.java
Log:
https://issues.jboss.org/browse/JBIDE-7741
Modified:
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 2010-12-13
15:43:46 UTC (rev 27412)
+++
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/browser/CSSBrowser.java 2010-12-13
16:43:24 UTC (rev 27413)
@@ -15,22 +15,22 @@
import org.eclipse.swt.SWTError;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.TypedEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
import org.jboss.tools.jst.css.CSSPlugin;
/**
* @author mareshkau
*
*/
-public class CSSBrowser extends Composite {
+public class CSSBrowser extends Composite implements CSSBrowserInterface {
- private Browser browser;
+ private CSSBrowserInterface browser;
- public Browser getBrowser() {
- return browser;
- }
/**
* If in system not installed xulrunner, than
* browser will be null
@@ -57,15 +57,20 @@
browser.setLayoutData(gridData);
browser.pack();
} catch(SWTError er){
- CSSPlugin.getDefault().logError(er);
+ CSSPlugin.getDefault().logWarning("Xulrunner implementation hasn't been
founded, so browser based preview " +
+ "will be not available");
}
- cssBrowser.setBrowser(browser);
+ if(browser!=null) {
+ cssBrowser.setBrowser(new CSSBrowserMozillaImplementation(browser));
+ } else {
+ Label label = new Label(cssBrowser,SWT.CENTER);
+ label.setText("Browser based preview not
availabe,"+System.getProperty("line.separator")+" see log for more
details");
+ label.setBounds(cssBrowser.getClientArea());
+ cssBrowser.setBrowser(new CSSBrowserEmptyImplementation());
+ }
return cssBrowser;
}
- public void setBrowser(Browser browser) {
- this.browser = browser;
- }
public void setLayoutData(GridData layoutData) {
super.setLayoutData(layoutData);
}
@@ -81,4 +86,13 @@
public void addMouseListener(MouseAdapter mouseAdapter) {
getBrowser().addMouseListener(mouseAdapter);
}
+ public boolean isBrowserEvent(TypedEvent e){
+ return getBrowser().isBrowserEvent(e);
+ }
+ private CSSBrowserInterface getBrowser() {
+ return this.browser;
+ }
+ private void setBrowser(CSSBrowserInterface browser) {
+ this.browser = browser;
+ }
}
Added:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/browser/CSSBrowserEmptyImplementation.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/browser/CSSBrowserEmptyImplementation.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/browser/CSSBrowserEmptyImplementation.java 2010-12-13
16:43:24 UTC (rev 27413)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.events.MouseAdapter;
+import org.eclipse.swt.events.TypedEvent;
+
+/**
+ * @author mareshkau
+ *
+ */
+public class CSSBrowserEmptyImplementation implements CSSBrowserInterface {
+
+ public boolean setFocus() {
+ return false;
+ }
+ public void setText(String generateBrowserPage) {
+ }
+ public void setEnabled(boolean isEnabled) {
+ }
+ public void addMouseListener(MouseAdapter mouseAdapter) {
+ }
+ public boolean isBrowserEvent(TypedEvent e){
+ return false;
+ }
+}
Added:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/browser/CSSBrowserInterface.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/browser/CSSBrowserInterface.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/browser/CSSBrowserInterface.java 2010-12-13
16:43:24 UTC (rev 27413)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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.events.MouseAdapter;
+import org.eclipse.swt.events.TypedEvent;
+
+/**
+ * @author mareshkau
+ *
+ */
+public interface CSSBrowserInterface {
+
+ public boolean setFocus();
+ public void setText(String generateBrowserPage);
+ public void setEnabled(boolean isEnabled);
+ public void addMouseListener(MouseAdapter mouseAdapter);
+ public boolean isBrowserEvent(TypedEvent e);
+
+}
Added:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/browser/CSSBrowserMozillaImplementation.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/browser/CSSBrowserMozillaImplementation.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/browser/CSSBrowserMozillaImplementation.java 2010-12-13
16:43:24 UTC (rev 27413)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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.browser.Browser;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.TypedEvent;
+
+/**
+ * @author mareshkau
+ *
+ */
+class CSSBrowserMozillaImplementation implements CSSBrowserInterface {
+ final private Browser browser;
+
+ public CSSBrowserMozillaImplementation(Browser browser) {
+ super();
+ this.browser = browser;
+ }
+ 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);
+ }
+ public boolean isBrowserEvent(TypedEvent e){
+ return e.widget==getBrowser();
+ }
+
+ private Browser getBrowser() {
+ return this.browser;
+ }
+
+}
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
15:43:46 UTC (rev 27412)
+++
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSPreview.java 2010-12-13
16:43:24 UTC (rev 27413)
@@ -87,7 +87,7 @@
browser.setLayoutData(gridData);
browser.addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(MouseEvent e) {
- if (e.widget == browser.getBrowser()) {
+ if (browser.isBrowserEvent(e)) {
browser.setEnabled(false);
previewComposite.setMaximizedControl(previewText);
previewText.setFocus();