JBoss Tools SVN: r4254 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2007-10-16 12:22:13 -0400 (Tue, 16 Oct 2007)
New Revision: 4254
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml
Log:
Sync with jbosstools_xulrunner branch
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml 2007-10-16 16:22:04 UTC (rev 4253)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml 2007-10-16 16:22:13 UTC (rev 4254)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<vpe:templates>
+ <vpe:template-taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j" />
<vpe:template-taglib uri="http://richfaces.org/a4j" prefix="a4j" />
- <vpe:template-taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j" />
<vpe:tag name="a4j:page" case-sensitive="yes">
<vpe:template children="yes" modify="yes">
@@ -317,12 +317,16 @@
<vpe:tag name="a4j:portlet" case-sensitive="yes">
<vpe:template children="yes" modify="no">
+ <span style="display:none">
+ </span>
</vpe:template>
</vpe:tag>
<vpe:tag name="a4j:push" case-sensitive="yes">
<vpe:template children="yes" modify="no">
+ <span style="display:none">
+ </span>
</vpe:template>
- </vpe:tag>
+ </vpe:tag>
</vpe:templates>
\ No newline at end of file
17 years, 3 months
JBoss Tools SVN: r4252 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.tomahawk/src/org/jboss/tools/jsf/vpe/tomahawk.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2007-10-16 12:20:58 -0400 (Tue, 16 Oct 2007)
New Revision: 4252
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.tomahawk/src/org/jboss/tools/jsf/vpe/tomahawk/TomahawkPlugin.java
Log:
Sync with jbosstools_xulrunner branch
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.tomahawk/src/org/jboss/tools/jsf/vpe/tomahawk/TomahawkPlugin.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.tomahawk/src/org/jboss/tools/jsf/vpe/tomahawk/TomahawkPlugin.java 2007-10-16 16:19:53 UTC (rev 4251)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.tomahawk/src/org/jboss/tools/jsf/vpe/tomahawk/TomahawkPlugin.java 2007-10-16 16:20:58 UTC (rev 4252)
@@ -10,10 +10,17 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.tomahawk;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
+import java.net.URL;
+
+import org.eclipse.ui.plugin.*;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-
+/**
+ * The main plugin class to be used in the desktop.
+ */
public class TomahawkPlugin extends AbstractUIPlugin {
//The shared instance.
@@ -47,5 +54,26 @@
public static TomahawkPlugin getDefault() {
return plugin;
}
-
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path.
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return AbstractUIPlugin.imageDescriptorFromPlugin("org.jboss.tools.jsf.vpe.otrix", path);
+ }
+
+ public static String getInstallPath() {
+ Bundle bundle = Platform.getBundle("org.jboss.tools.jsf.vpe.otrix");
+ URL url = null;
+ try {
+ url = bundle == null ? null : Platform.resolve(bundle.getEntry("/"));
+ } catch (Exception e) {
+ url = bundle.getEntry("/");
+ }
+ return (url == null) ? null : url.getPath();
+ }
}
17 years, 3 months
JBoss Tools SVN: r4251 - in trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner: META-INF and 9 other directories.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2007-10-16 12:19:53 -0400 (Tue, 16 Oct 2007)
New Revision: 4251
Added:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/.classpath
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/.project
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/META-INF/
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/META-INF/MANIFEST.MF
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/build.properties
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/BrowserPlugin.java
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/XPCOM.java
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/XulRunnerException.java
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/AppFileLocProvider.java
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/WindowCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/util/
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/util/DOMTreeDumper.java
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/IVpeResizeListener.java
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/IXulRunnerVpeResizer.java
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/VpeResizerMouseListener.java
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/VpeResizerMouseMotionListener.java
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerConstants.java
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeResizer.java
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeUtils.java
Log:
Sync with jbosstools_xulrunner branch
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/.classpath
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/.classpath (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/.classpath 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/.project
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/.project (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/.project 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.vpe.xulrunner</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/META-INF/MANIFEST.MF
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/META-INF/MANIFEST.MF (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/META-INF/MANIFEST.MF 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Browser (XULRunner) Plug-in
+Bundle-SymbolicName: org.jboss.tools.vpe.xulrunner;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.jboss.tools.vpe.xulrunner.BrowserPlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.mozilla.xpcom,
+ org.jboss.tools.common
+Eclipse-LazyStart: true
+Export-Package: org.jboss.tools.vpe.xulrunner;uses:="org.eclipse.jface.resource,org.eclipse.ui.plugin,org.osgi.framework",
+ org.jboss.tools.vpe.xulrunner.browser;uses:="org.mozilla.interfaces,org.eclipse.swt.widgets,org.mozilla.xpcom",
+ org.jboss.tools.vpe.xulrunner.browser.util,
+ org.jboss.tools.vpe.xulrunner.editor
+Bundle-ClassPath: .
+Bundle-Vendor: Red Hat, Inc.
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/build.properties
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/build.properties (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/build.properties 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/BrowserPlugin.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/BrowserPlugin.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/BrowserPlugin.java 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,67 @@
+package org.jboss.tools.vpe.xulrunner;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.jboss.tools.common.log.BaseUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class BrowserPlugin extends BaseUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.vpe.xulrunner"; // $NON-NLS-1$
+
+ public static final boolean DEBUG_BROWSERSTART;
+ // The shared instance
+ private static BrowserPlugin plugin;
+
+ static {
+ DEBUG_BROWSERSTART = "true".equals(Platform.getDebugOption(PLUGIN_ID + "/debug/browser_start")); // $NON-NLS-1$ // $NON-NLS-1$
+ }
+
+ /**
+ * The constructor
+ */
+ public BrowserPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static BrowserPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/XPCOM.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/XPCOM.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/XPCOM.java 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.vpe.xulrunner;
+
+/**
+ * @author Sergey Vasilyev (svasilyev(a)exadel.com)
+ *
+ */
+public final class XPCOM {
+ private XPCOM() {};
+ /*
+ * Contract IDs
+ */
+ public static final String NS_DRAGSERVICE_CONTRACTID = "@mozilla.org/widget/dragservice;1;"; //$NON-NLS-1$
+ public static final String NS_TRANSFERABLE_CONTRACTID = "@mozilla.org/widget/transferable;1"; //$NON-NLS-1$
+ public static final String NS_WINDOWWATCHER_CONTRACTID = "@mozilla.org/embedcomp/window-watcher;1"; //$NON-NLS-1$
+ public static final String NS_PREFSERVICE_CONTRACTID = "@mozilla.org/preferences-service;1"; //$NON-NLS-1$
+ public static final String IN_FLASHER_CONTRACTID = "@mozilla.org/inspector/flasher;1";
+
+ public static final String NS_IWEBBROWSER_CID = "F1EAC761-87E9-11d3-AF80-00A024FFC08C"; // $NON-NLS-1$
+ public static final String NS_IAPPSHELL_CID = "2d96b3df-c051-11d1-a827-0040959a28c9"; // $NON-NLS-1$
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/XulRunnerException.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/XulRunnerException.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/XulRunnerException.java 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,22 @@
+package org.jboss.tools.vpe.xulrunner;
+
+public class XulRunnerException extends Exception {
+ private static final long serialVersionUID = -7973228286977485907L;
+
+ public XulRunnerException() {
+ super();
+ }
+
+ public XulRunnerException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public XulRunnerException(String message) {
+ super(message);
+ }
+
+ public XulRunnerException(Throwable cause) {
+ super(cause);
+ }
+
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/AppFileLocProvider.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/AppFileLocProvider.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/AppFileLocProvider.java 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,74 @@
+package org.jboss.tools.vpe.xulrunner.browser;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.Platform;
+import org.jboss.tools.vpe.xulrunner.BrowserPlugin;
+import org.mozilla.xpcom.IAppFileLocProvider;
+
+public class AppFileLocProvider implements IAppFileLocProvider {
+ private File xulRunnerPath;
+ private File userDataPath;
+
+ private static final String PLUGINS_DIRECTORY = "plugins"; // $NON-NLS-1$
+ private static final String HISTORY_FILE = "history.dat"; // $NON-NLS-1$
+ private static final String COMPREG_FILE = "compreg.dat"; // $NON-NLS-1$
+ private static final String XPTI_FILE = "xpti.dat"; // $NON-NLS-1$
+ private static final String COMPONENTS_DIRECTORY = "components"; //$NON-NLS-1$
+
+
+ public AppFileLocProvider(File xulRunnerPath) {
+ this.xulRunnerPath = xulRunnerPath;
+ this.userDataPath = Platform.getLocation().append(".metadata/.plugins") // $NON-NLS-1$
+ .append(BrowserPlugin.PLUGIN_ID)
+ .append("xulrunner").toFile(); // $NON-NLS-1$
+ }
+
+ public File getFile(String prop, boolean[] persistent) {
+ persistent[0] = false;
+
+ File resultFile = null;
+
+ if ("ProfD".equals(prop)) { // $NON-NLS-1$
+ resultFile = userDataPath;
+ } else if ("UHist".equals(prop)) { // $NON-NLS-1$
+ resultFile = new File(userDataPath, HISTORY_FILE);
+ } else if ("ComRegF".equals(prop)) { // $NON-NLS-1$
+ resultFile = new File(userDataPath, COMPREG_FILE);
+ } else if ("XptiRegF".equals(prop)) { // $NON-NLS-1$
+ resultFile = new File(userDataPath, XPTI_FILE);
+ } else if ("GreD".equals(prop)) { // $NON-NLS-1$
+ resultFile = xulRunnerPath;
+ } else if ("GreComsD".equals(prop) || "ComsD".equals(prop)) { // $NON-NLS-1$ // $NON-NLS-1$
+ resultFile = new File(xulRunnerPath, COMPONENTS_DIRECTORY);
+ }
+
+ if (BrowserPlugin.DEBUG_BROWSERSTART) {
+ System.out.println("AppFileLocProvider.getFile(" + prop + ")=\"" + (resultFile == null ? "null" : resultFile.toString()) + "\"");
+ }
+
+ return resultFile;
+ }
+
+ public File[] getFiles(String prop) {
+ File[] resultFiles = null;
+ if("APluginsDL".equals(prop)) { // $NON-NLS-1$
+ resultFiles = new File[] {new File(xulRunnerPath, PLUGINS_DIRECTORY)};
+ }
+
+ if (BrowserPlugin.DEBUG_BROWSERSTART) {
+ if (resultFiles != null) {
+ int size = resultFiles.length;
+
+ System.out.print("AppFileLocProvider.getFiles(" + prop + ")={\"");
+ for(int i=0; i<size; i++) {
+ System.out.print((i > 0 ? ", " : "") + resultFiles[i].toString());
+ }
+ System.out.println("\"}");
+ }
+ }
+
+ return resultFiles;
+ }
+
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/WindowCreator.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/WindowCreator.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/WindowCreator.java 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,32 @@
+package org.jboss.tools.vpe.xulrunner.browser;
+
+import org.mozilla.interfaces.nsISupports;
+import org.mozilla.interfaces.nsIURI;
+import org.mozilla.interfaces.nsIWebBrowserChrome;
+import org.mozilla.interfaces.nsIWindowCreator;
+import org.mozilla.interfaces.nsIWindowCreator2;
+import org.mozilla.xpcom.Mozilla;
+
+public class WindowCreator implements nsIWindowCreator, nsIWindowCreator2 {
+
+ public nsIWebBrowserChrome createChromeWindow(nsIWebBrowserChrome arg0,
+ long arg1) {
+ // TODO Sergey Vasilyev implement
+ System.out.println("WindowCreator:createChromeWindow(" + arg0 +", " + arg1 + ")");
+ return arg0;
+ }
+
+ public nsISupports queryInterface(String arg0) {
+ // TODO Auto-generated method stub
+ return Mozilla.queryInterface(this, arg0);
+ }
+
+ public nsIWebBrowserChrome createChromeWindow2(nsIWebBrowserChrome arg0,
+ long arg1, long arg2, nsIURI arg3, boolean[] arg4) {
+ // TODO Sergey Vasilyev implement
+ System.out.println("WindowCreator:createChromeWindow2(" + arg0 +", "
+ + arg1 + ", "+ arg2 + ", "+ (arg3 == null ? "null" : arg3.getSpec()) +")");
+ return arg0;
+ }
+
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,404 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.vpe.xulrunner.browser;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Listener;
+import org.jboss.tools.vpe.xulrunner.XPCOM;
+import org.jboss.tools.vpe.xulrunner.XulRunnerException;
+import org.mozilla.interfaces.nsIComponentManager;
+import org.mozilla.interfaces.nsIPrefService;
+import org.mozilla.interfaces.nsIRequest;
+import org.mozilla.interfaces.nsIServiceManager;
+import org.mozilla.interfaces.nsISupports;
+import org.mozilla.interfaces.nsITooltipListener;
+import org.mozilla.interfaces.nsIURI;
+import org.mozilla.interfaces.nsIWebBrowser;
+import org.mozilla.interfaces.nsIWebBrowserChrome;
+import org.mozilla.interfaces.nsIWebBrowserSetup;
+import org.mozilla.interfaces.nsIWebNavigation;
+import org.mozilla.interfaces.nsIWebProgress;
+import org.mozilla.interfaces.nsIWebProgressListener;
+import org.mozilla.xpcom.GREVersionRange;
+import org.mozilla.xpcom.Mozilla;
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * @author Sergey Vasilyev (svasilyev(a)exadel.com)
+ *
+ */
+
+public class XulRunnerBrowser implements nsIWebBrowserChrome,
+ nsIWebProgressListener, nsITooltipListener {
+ private static final String XULRUNNER_LOWER_VERSION = "1.8.1.2";
+ private static final String XULRUNNER_HIGHER_VERSION = "*";
+ // TODO Sergey Vasilyev Think. May be XULRUNNER_BUNDLE shouldn't be final?
+ private static final String XULRUNNER_BUNDLE;
+ private static final String XULRUNNER_ENTRY = "/xulrunner";
+
+ // TEMPORARY CODE (@see org.eclipse.swt.browser.Mozilla)
+ static final String XULRUNNER_INITIALIZED = "org.eclipse.swt.browser.XULRunnerInitialized"; //$NON-NLS-1$
+ static final String XULRUNNER_PATH = "org.eclipse.swt.browser.XULRunnerPath"; //$NON-NLS-1$
+
+ private static final String ROOT_BRANCH_NAME = ""; //$NON-NLS-1$
+
+ private static final String PREFERENCE_DISABLEOPENDURINGLOAD = "dom.disable_open_during_load"; //$NON-NLS-1$
+ private static final String PREFERENCE_DISABLEWINDOWSTATUSCHANGE = "dom.disable_window_status_change"; //$NON-NLS-1$
+
+ private static final Mozilla mozilla;
+ private Browser browser = null;
+ private nsIWebBrowser webBrowser = null;
+ private long chrome_flags = nsIWebBrowserChrome.CHROME_ALL;
+
+ static {
+ XULRUNNER_BUNDLE = (new StringBuffer("org.mozilla.xulrunner")) // $NON-NLS-1$
+ .append(".").append(Platform.getWS()) // $NON-NLS-1$
+ .append(".").append(Platform.getOS()) // $NON-NLS-1$
+ .append(Platform.OS_MACOSX.equals(Platform.getOS()) ? "" : (new StringBuffer(".")).append(Platform.getOSArch()).toString()) // $NON-NLS-1$ // $NON-NLS-1$
+ .toString();
+
+ mozilla = Mozilla.getInstance();
+ }
+
+ public XulRunnerBrowser(Composite parent) throws XulRunnerException {
+ initXulRunner();
+
+ browser = new Browser(parent, SWT.MOZILLA);
+
+ webBrowser = (nsIWebBrowser) browser.getWebBrowser();
+ if (webBrowser == null) {
+ throw new XulRunnerException("nsIWebBrowser is not available"); // $NON-NLS-1$
+ }
+
+ setBoolRootPref(PREFERENCE_DISABLEOPENDURINGLOAD, true);
+ setBoolRootPref(PREFERENCE_DISABLEWINDOWSTATUSCHANGE, true);
+
+ nsIWebBrowserSetup setup = (nsIWebBrowserSetup) webBrowser.queryInterface(nsIWebBrowserSetup.NS_IWEBBROWSERSETUP_IID);
+ setup.setProperty(nsIWebBrowserSetup.SETUP_IS_CHROME_WRAPPER, 1);
+
+ webBrowser.addWebBrowserListener(this, nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID);
+ webBrowser.addWebBrowserListener(this, nsITooltipListener.NS_ITOOLTIPLISTENER_IID);
+ }
+
+ public synchronized void initXulRunner() throws XulRunnerException {
+ String xulRunnerPath = getXulRunnerPath();
+
+ Boolean isXulRunnerInitialized = "true".equals(System.getProperty(XULRUNNER_INITIALIZED)); // $NON-NLS-1$
+ if (!isXulRunnerInitialized) {
+ File file = new File(xulRunnerPath);
+ mozilla.initialize(file);
+ mozilla.initEmbedding(file, file, new AppFileLocProvider(file));
+ System.setProperty(XULRUNNER_INITIALIZED, "true"); // $NON-NLS-1$
+ }
+ }
+
+ /**
+ * Decorate Widget.getDisplay()
+ */
+ public Display getDisplay() {
+ return browser.getDisplay();
+ }
+
+ /**
+ * Decorate Control.setCursor(org.eclipse.swt.graphics.Cursor)
+ */
+ public void setCursor(Cursor cursor) {
+ browser.setCursor(cursor);
+ }
+
+ /**
+ * Decorate Composite.setFocus()
+ */
+ public boolean setFocus() {
+ return browser.setFocus();
+ }
+
+ /**
+ * Decorate Control.setLayoutData(Object)
+ */
+ public void setLayoutData(Object layoutData) {
+ browser.setLayoutData(layoutData);
+ }
+
+ /**
+ * Decorate Widget.addListener(int eventType, Listener listener)
+ */
+ public void addListener(int eventType, Listener listener) {
+ browser.addListener(eventType, listener);
+ }
+
+ /**
+ * Decorate Widget.dispose()
+ */
+ public void dispose() {
+ browser.dispose();
+
+ }
+
+ public static String getXulRunnerBundle() {
+ return XULRUNNER_BUNDLE;
+ }
+
+ public synchronized static String getXulRunnerPath() throws XulRunnerException {
+ String xulRunnerPath = System.getProperty(XULRUNNER_PATH);
+ if (xulRunnerPath == null) {
+ GREVersionRange[] greRanges = {new GREVersionRange(XULRUNNER_LOWER_VERSION, true, XULRUNNER_HIGHER_VERSION, true)};
+ File xulRunnerFile = null;
+
+ try {
+ xulRunnerFile = Mozilla.getGREPathWithProperties(greRanges, null);
+ } catch (FileNotFoundException fnfe) {
+ // Ignre this exception. Will try to get XULRunner from plugin
+ }
+
+ if (xulRunnerFile == null
+ || !xulRunnerFile.exists()) {
+ Bundle xulRunnerBundle = Platform.getBundle(getXulRunnerBundle());
+ if (xulRunnerBundle == null) {
+ throw new XulRunnerException("Bundle " + getXulRunnerBundle() + " is not found.");
+ }
+
+ String xulRunnerVersion = (String) xulRunnerBundle.getHeaders().get("Bundle-Version");
+ if (!greRanges[0].check(xulRunnerVersion)) {
+ throw new XulRunnerException("the version of the bundled XULRunner must be >= 1.8.1.2 ");
+ }
+
+
+ URL url = xulRunnerBundle.getEntry(XULRUNNER_ENTRY);
+ if (url == null) {
+ throw new XulRunnerException("Bundle " + getXulRunnerBundle() + " doesn't contain /xulrunner");
+ }
+
+ try {
+ URL url1 = FileLocator.resolve(url);
+ xulRunnerFile = new File(FileLocator.toFileURL(url1).getFile());
+ } catch (IOException ioe) {
+ throw new XulRunnerException("Cannot get path to XULRunner from bundle " + getXulRunnerBundle(), ioe); // $NON-NLS-1$
+ }
+ }
+
+ xulRunnerPath = xulRunnerFile.getAbsolutePath();
+ System.setProperty(XULRUNNER_PATH, xulRunnerPath);
+ }
+
+
+ return xulRunnerPath;
+ }
+
+ public nsIServiceManager getServiceManager() {
+ return mozilla.getServiceManager();
+ }
+
+ public nsIComponentManager getComponentManager() {
+ return mozilla.getComponentManager();
+ }
+
+ public void setURL(String url) {
+ nsIWebNavigation webNavigation = (nsIWebNavigation) webBrowser.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
+ webNavigation.loadURI(url, nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
+ }
+
+ public String getURL() {
+ nsIWebNavigation webNavigation = (nsIWebNavigation) webBrowser.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
+ return webNavigation.getCurrentURI().getSpec();
+ }
+
+ public void stop() {
+ nsIWebNavigation webNavigation = (nsIWebNavigation) webBrowser.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
+ webNavigation.stop(nsIWebNavigation.STOP_ALL);
+ }
+
+ public void reload() {
+ nsIWebNavigation webNavigation = (nsIWebNavigation) webBrowser.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
+ webNavigation.reload(nsIWebNavigation.LOAD_FLAGS_NONE);
+ }
+
+ public void goBack() {
+ nsIWebNavigation webNavigation = (nsIWebNavigation) webBrowser.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
+ webNavigation.goBack();
+ }
+
+ public void goForward() {
+ nsIWebNavigation webNavigation = (nsIWebNavigation) webBrowser.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
+ webNavigation.goForward();
+ }
+
+ public void onLoadWindow() {
+ }
+
+ public nsIPrefService getPrefService() {
+ return (nsIPrefService) getServiceManager().getServiceByContractID(XPCOM.NS_PREFSERVICE_CONTRACTID, nsIPrefService.NS_IPREFSERVICE_IID);
+ }
+
+
+ public void setBoolRootPref(String aPrefName, boolean aValue) {
+ getPrefService().getBranch(ROOT_BRANCH_NAME).setBoolPref(aPrefName, aValue ? 1 : 0);
+ }
+
+
+ public void setCharRootPref(String aPrefName, String aValue) {
+ getPrefService().getBranch(ROOT_BRANCH_NAME).setCharPref(aPrefName, aValue);
+ }
+
+
+ public void setComplexRootValue(String aPrefName, String aType, nsISupports aValue) {
+ getPrefService().getBranch(ROOT_BRANCH_NAME).setComplexValue(aPrefName, aType, aValue);
+ }
+
+ public void setIntRootPref(String aPrefName, int aValue) {
+ getPrefService().getBranch(ROOT_BRANCH_NAME).setIntPref(aPrefName, aValue);
+ }
+
+ public boolean getBoolRootPref(String aPrefName) {
+ return getPrefService().getBranch(ROOT_BRANCH_NAME).getBoolPref(aPrefName);
+ }
+
+ public String getCharRootPref(String aPrefName) {
+ return getPrefService().getBranch(ROOT_BRANCH_NAME).getCharPref(aPrefName);
+ }
+
+ public nsISupports getComplextRootPref(String aPrefName, String aType) {
+ return getPrefService().getBranch(ROOT_BRANCH_NAME).getComplexValue(aPrefName, aType);
+ }
+
+ public int getIntRootf(String aPrefName) {
+ return getPrefService().getBranch(ROOT_BRANCH_NAME).getIntPref(aPrefName);
+ }
+
+ /*
+ * nsISupports
+ *
+ * @see org.mozilla.interfaces.nsISupports#queryInterface(java.lang.String)
+ */
+ public nsISupports queryInterface(String arg0) {
+ return Mozilla.queryInterface(this, arg0);
+ }
+
+ /*
+ * nsIWebBrowserChrome
+ *
+ * @see org.mozilla.interfaces.nsIWebBrowserChrome
+ */
+ public void destroyBrowserWindow() {
+ // TODO Sergey Vasilyev implement
+ throw new RuntimeException("Not implemented");
+ }
+
+ public void exitModalEventLoop(long arg0) {
+ throw new RuntimeException("Not implemented");
+ }
+
+ public long getChromeFlags() {
+ return chrome_flags;
+ }
+
+ public nsIWebBrowser getWebBrowser() {
+ return webBrowser;
+ }
+
+ public boolean isWindowModal() {
+ // TODO Sergey Vasilyev implement
+ return false;
+ }
+
+ public void setChromeFlags(long arg0) {
+ chrome_flags = arg0;
+ }
+
+ public void setStatus(long arg0, String arg1) {
+ // TODO Sergey Vasilyev implement
+ throw new RuntimeException("Not implemented");
+ }
+
+ public void setWebBrowser(nsIWebBrowser arg0) {
+ webBrowser = arg0;
+ }
+
+ public void showAsModal() {
+ // TODO Sergey Vasilyev implement
+ throw new RuntimeException("Not implemented");
+ }
+
+ public void sizeBrowserTo(int arg0, int arg1) {
+ // TODO Sergey Vasilyev implement
+ throw new RuntimeException("Not implemented");
+ }
+
+ /* (non-Javadoc)
+ * @see org.mozilla.interfaces.nsIWebProgressListener#onLocationChange(org.mozilla.interfaces.nsIWebProgress, org.mozilla.interfaces.nsIRequest, org.mozilla.interfaces.nsIURI)
+ */
+ public void onLocationChange(nsIWebProgress arg0, nsIRequest arg1,
+ nsIURI arg2) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.mozilla.interfaces.nsIWebProgressListener#onProgressChange(org.mozilla.interfaces.nsIWebProgress, org.mozilla.interfaces.nsIRequest, int, int, int, int)
+ */
+ public void onProgressChange(nsIWebProgress arg0, nsIRequest arg1,
+ int arg2, int arg3, int arg4, int arg5) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.mozilla.interfaces.nsIWebProgressListener#onSecurityChange(org.mozilla.interfaces.nsIWebProgress, org.mozilla.interfaces.nsIRequest, long)
+ */
+ public void onSecurityChange(nsIWebProgress arg0, nsIRequest arg1, long arg2) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.mozilla.interfaces.nsIWebProgressListener#onStateChange(org.mozilla.interfaces.nsIWebProgress, org.mozilla.interfaces.nsIRequest, long, long)
+ */
+ public void onStateChange(nsIWebProgress aWebProgress, nsIRequest aRequest, long aStateFlags, long aStstus) {
+ if ((aStateFlags & nsIWebProgressListener.STATE_IS_WINDOW) != 0
+ && (aStateFlags & nsIWebProgressListener.STATE_STOP) != 0) {
+ onLoadWindow();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.mozilla.interfaces.nsIWebProgressListener#onStatusChange(org.mozilla.interfaces.nsIWebProgress, org.mozilla.interfaces.nsIRequest, long, java.lang.String)
+ */
+ public void onStatusChange(nsIWebProgress arg0, nsIRequest arg1, long aStatus, String message) {
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.mozilla.interfaces.nsITooltipListener#onHideTooltip()
+ */
+ public void onHideTooltip() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.mozilla.interfaces.nsITooltipListener#onShowTooltip(int, int, java.lang.String)
+ */
+ public void onShowTooltip(int aXCoords, int aYCoords, String aTipText) {
+ }
+
+ /**
+ * @return the browser
+ */
+ public Browser getBrowser() {
+ return browser;
+ }
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/util/DOMTreeDumper.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/util/DOMTreeDumper.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/util/DOMTreeDumper.java 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.xulrunner.browser.util;
+
+import java.io.PrintStream;
+
+import org.mozilla.interfaces.nsIDOMAttr;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNamedNodeMap;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMNodeList;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class DOMTreeDumper {
+ private PrintStream ps;
+ private boolean inA;
+ private final String[] endTagForbiddenNames = {"AREA",
+ "BASE",
+ "BASEFONT",
+ "BR",
+ "COL",
+ "FRAME",
+ "HR",
+ "IMG",
+ "INPUT",
+ "ISINDEX",
+ "LINK",
+ "META",
+ "PARAM"};
+
+ public void dumpToStream(PrintStream ps, nsIDOMDocument doc) {
+ this.ps = ps;
+ dumpDocument(doc);
+ }
+
+ private void dumpDocument(nsIDOMDocument doc) {
+ if (doc == null) {
+ return;
+ }
+ nsIDOMElement element = doc.getDocumentElement();
+ if (element == null) return;
+
+ dumpNode((nsIDOMNode)element.queryInterface(nsIDOMNode.NS_IDOMNODE_IID));
+ ps.println();
+ ps.flush();
+
+ element = null;
+ doc = null;
+ }
+
+ private void dumpNode(nsIDOMNode node) {
+ dumpNode(node, false);
+ }
+
+ private void dumpNode(nsIDOMNode node, boolean isMapNode) {
+ if (node == null) {
+ return;
+ }
+
+ int type = node.getNodeType();
+ String name = node.getNodeName();
+ String value = node.getNodeValue();
+
+ switch (type) {
+ case Node.ELEMENT_NODE:
+ if (name.equals("A")) {
+ inA = true;
+ }
+ if (!(inA || name.equals("BR"))) {
+ ps.println();
+ }
+ ps.print("<" + name);
+ dumpAttributes(node);
+ ps.print(">(" + node.hashCode() + ")");
+ dumpChildren(node);
+ if (name.equals("A")) {
+ inA = false;
+ }
+ if (!endTagForbidden(name)) {
+ ps.print("</" + name + ">");
+ }
+ break;
+
+ case Node.ATTRIBUTE_NODE:
+ nsIDOMAttr attr = (nsIDOMAttr) node.queryInterface(nsIDOMAttr.NS_IDOMATTR_IID);
+ if (attr.getSpecified()) {
+ ps.print(" " + attr.getName().toUpperCase() + "=\"" + attr.getValue() + "\"");
+ } else {
+ ps.print(" " + attr.getName().toUpperCase());
+ }
+ break;
+
+ case Node.TEXT_NODE:
+ if (!node.getParentNode().getNodeName().equals("PRE")) {
+ value = value.trim();
+ }
+ if (!value.equals("")) {
+ if (!inA) {
+ ps.println();
+ }
+ ps.print(canonicalize(value));
+ }
+ ps.print("(" + node.hashCode() + ")");
+ break;
+ case Node.COMMENT_NODE:
+ ps.print("\n<!--" + value + "-->");
+ break;
+ case Node.CDATA_SECTION_NODE:
+ case Node.ENTITY_REFERENCE_NODE:
+ case Node.ENTITY_NODE:
+ case Node.PROCESSING_INSTRUCTION_NODE:
+ case Node.DOCUMENT_NODE:
+ case Node.DOCUMENT_TYPE_NODE:
+ case Node.DOCUMENT_FRAGMENT_NODE:
+ case Node.NOTATION_NODE:
+ ps.println("\n<!-- NOT HANDLED: " + name +
+ " value=" + value + " -->");
+ break;
+ }
+ }
+
+ private void dumpAttributes(nsIDOMNode node) {
+ nsIDOMNamedNodeMap map = node.getAttributes();
+ if (map == null) {
+ return;
+ }
+ long length = map.getLength();
+ for (int i=0; i < length; i++) {
+ dumpNode(map.item(i), true);
+ }
+ }
+
+ private void dumpChildren(nsIDOMNode node) {
+ nsIDOMNodeList children = node.getChildNodes();
+ if (children == null) {
+ return;
+ }
+ long length = children.getLength();
+ for (int i = 0; i < length; i++) {
+ dumpNode(children.item(i));
+ }
+ if (!inA) {
+ ps.println();
+ }
+ }
+
+ private String canonicalize(String str) {
+ StringBuffer in = new StringBuffer(str);
+ int length = in.length();
+ StringBuffer out = new StringBuffer(length);
+ char c;
+ for (int i = 0; i < length; i++) {
+ switch (c = in.charAt(i)) {
+ case '&' :
+ out.append("&");
+ break;
+ case '<':
+ out.append("<");
+ break;
+ case '>':
+ out.append(">");
+ break;
+ case '\u00A0':
+ out.append(" ");
+ break;
+ default:
+ out.append(c);
+ }
+ }
+ return out.toString();
+ }
+
+ private boolean endTagForbidden(String name) {
+ for (int i = 0; i < endTagForbiddenNames.length; i++) {
+ if (name.equals(endTagForbiddenNames[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
\ No newline at end of file
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/IVpeResizeListener.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/IVpeResizeListener.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/IVpeResizeListener.java 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.vpe.xulrunner.editor;
+
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsISupports;
+
+/**
+ * a IVpeResizeListener interface
+ * @author A. Yukhovich
+ */
+public interface IVpeResizeListener extends nsISupports {
+ /**
+ * Event handler for 'object end resizing'
+ * @param usedResizeMarkerHandle a used resize marker handle
+ * @param top a new top position
+ * @param left a new left position
+ * @param width a new width
+ * @param height a new height
+ * @param resizedDomElement a resized nsIDOMElement
+ */
+ public void onEndResizing(int usedResizeMarkerHandle, int top, int left, int width, int height, nsIDOMElement resizedDomElement);
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/IXulRunnerVpeResizer.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/IXulRunnerVpeResizer.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/IXulRunnerVpeResizer.java 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.vpe.xulrunner.editor;
+
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMEvent;
+
+/**
+ * IXulRunnerVpeResizer interface class
+ * @author A. Yukhovich
+ */
+public interface IXulRunnerVpeResizer {
+ /** RESIZER_MARKER_TOPLEFT */
+ final static public int RESIZER_MARKER_TOPLEFT = 1;
+
+ /** RESIZER_MARKER_TOP */
+ final static public int RESIZER_MARKER_TOP = 2;
+
+ /** RESIZER_MARKER_TOPRIGHT */
+ final static public int RESIZER_MARKER_TOPRIGHT = 4;
+
+ /** RESIZER_MARKER_LEFT */
+ final static public int RESIZER_MARKER_LEFT = 8;
+
+ /** RESIZER_MARKER_RIGHT */
+ final static public int RESIZER_MARKER_RIGHT = 16;
+
+ /** RESIZER_MARKER_BOTTOMLEFT */
+ final static public int RESIZER_MARKER_BOTTOMLEFT = 32;
+
+ /** RESIZER_MARKER_BOTTOM */
+ final static public int RESIZER_MARKER_BOTTOM = 64;
+
+ /** RESIZER_MARKER_BOTTOMRIGHT */
+ final static public int RESIZER_MARKER_BOTTOMRIGHT = 128;
+
+
+ public void init(nsIDOMDocument domDocument);
+
+ /**
+ * Show resize markers
+ * @param domElement
+ * @param resizers
+ */
+ public void show(nsIDOMElement domElement, int resizers);
+
+ /**
+ * Hide resize markers
+ */
+ public void hide();
+
+ /**
+ * Event handler MouseDown
+ * @param clientX
+ * @param clientY
+ * @param domElement a target nsIDOMElement
+ */
+ public void mouseDown(int clientX, int clientY, nsIDOMElement domElement);
+
+ /**
+ * Event handler MouseMove
+ * @param event
+ */
+ public void mouseMove(nsIDOMEvent event);
+
+ /**
+ * Event handler MouseUp
+ * @param clientX
+ * @param clientY
+ * @param target a target nsIDOMElement
+ */
+ public void mouseUp(int clientX, int clientY, nsIDOMElement target);
+
+ /**
+ * add resize listener to queue
+ * @param aListener a IVpeResizeListener object
+ */
+ public void addResizeListener(IVpeResizeListener aListener);
+
+ /**
+ * remove resize listener from queue
+ * @param aListener a IVpeResizeListener object
+ */
+ public void removeResizeListener(IVpeResizeListener aListener);
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/VpeResizerMouseListener.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/VpeResizerMouseListener.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/VpeResizerMouseListener.java 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.vpe.xulrunner.editor;
+
+import org.eclipse.core.runtime.Platform;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMEvent;
+import org.mozilla.interfaces.nsIDOMEventListener;
+import org.mozilla.interfaces.nsIDOMEventTarget;
+import org.mozilla.interfaces.nsIDOMMouseEvent;
+import org.mozilla.interfaces.nsIDOMNSEvent;
+import org.mozilla.interfaces.nsISupports;
+import org.mozilla.xpcom.Mozilla;
+
+/**
+ *
+ * @author A. Yukhovich
+ */
+public class VpeResizerMouseListener implements nsIDOMEventListener {
+
+ private IXulRunnerVpeResizer vpeResizer;
+
+ /**
+ * Default contructor
+ */
+ public VpeResizerMouseListener(IXulRunnerVpeResizer vpeResizer) {
+ super();
+ this.vpeResizer = vpeResizer;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.mozilla.interfaces.nsIDOMEventListener#handleEvent(org.mozilla.interfaces.nsIDOMEvent)
+ */
+ public void handleEvent(nsIDOMEvent event) {
+ nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent) event
+ .queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+
+ if (mouseEvent == null) {
+ return;
+ }
+
+ if (XulRunnerConstants.EVENT_NAME_MOUSEDOWN.equals(mouseEvent.getType())) {
+ mouseDown(mouseEvent);
+ } else if (XulRunnerConstants.EVENT_NAME_MOUSEUP.equals(mouseEvent.getType())) {
+ mouseUp(mouseEvent);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.mozilla.interfaces.nsISupports#queryInterface(java.lang.String)
+ */
+ public nsISupports queryInterface(String aIID) {
+ if (aIID.equals(nsIDOMEventListener.NS_IDOMEVENTLISTENER_IID)) {
+ return this;
+ } // if
+
+ return Mozilla.queryInterface(this, aIID);
+ }
+
+ /**
+ * processing event of mouseDown
+ *
+ * @param mouseEvent
+ * a nsIDOMMouseEvent object
+ */
+ private void mouseDown(nsIDOMMouseEvent mouseEvent) {
+ boolean isContextClick = false;
+
+ if (Platform.getOS().equals("SunOS")) {
+ isContextClick = mouseEvent.getCtrlKey();
+ } else {
+ isContextClick = (mouseEvent.getButton() == 2);
+ }
+
+ if (!isContextClick && (mouseEvent.getButton() == 0)
+ && (mouseEvent.getDetail() == 1)) {
+ nsIDOMNSEvent internalEvent = (nsIDOMNSEvent) mouseEvent
+ .queryInterface(nsIDOMNSEvent.NS_IDOMNSEVENT_IID);
+ if (internalEvent != null) {
+ org.mozilla.interfaces.nsIDOMEventTarget eventTarget = internalEvent
+ .getExplicitOriginalTarget();
+ if (eventTarget != null) {
+ nsIDOMElement domElement = (nsIDOMElement) eventTarget
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ if (domElement != null) {
+ int clientX = mouseEvent.getClientX();
+ int clientY = mouseEvent.getClientY();
+
+ vpeResizer.mouseDown(clientX, clientY, domElement);
+ }
+ } // if
+ } // if
+
+ }
+ }
+
+ /**
+ * processing event of mouseUp
+ *
+ * @param mouseEvent
+ * a nsIDOMMouseEvent object
+ */
+ private void mouseUp(nsIDOMMouseEvent mouseEvent) {
+ nsIDOMEventTarget target = mouseEvent.getTarget();
+
+ if (target != null ) {
+ nsIDOMElement domElement = (nsIDOMElement) target.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ if (domElement != null) {
+ int clientX = mouseEvent.getClientX();
+ int clientY = mouseEvent.getClientY();
+ vpeResizer.mouseUp(clientX, clientY, domElement);
+ }
+ }
+ }
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/VpeResizerMouseMotionListener.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/VpeResizerMouseMotionListener.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/VpeResizerMouseMotionListener.java 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.vpe.xulrunner.editor;
+
+import org.mozilla.interfaces.nsIDOMEvent;
+import org.mozilla.interfaces.nsIDOMEventListener;
+import org.mozilla.interfaces.nsIDOMMouseEvent;
+import org.mozilla.interfaces.nsISupports;
+import org.mozilla.xpcom.Mozilla;
+
+/**
+ * @author A. Yukhovich
+ */
+public class VpeResizerMouseMotionListener implements nsIDOMEventListener {
+ /** vpeRezizer */
+ private IXulRunnerVpeResizer vpeResizer;
+
+ /**
+ * Default constructor
+ * @param vpeResizer a IVpeResizer object
+ */
+ public VpeResizerMouseMotionListener(IXulRunnerVpeResizer vpeResizer) {
+ this.vpeResizer = vpeResizer;
+ }
+
+ /**
+ * mouse move
+ * @param event a nsIDOMEvent object
+ */
+ public void mouseMove(nsIDOMEvent event) {
+ nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent) event.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+
+ if ( mouseEvent == null ) {
+ return;
+ }
+ vpeResizer.mouseMove(mouseEvent);
+ }
+
+ public void dragMove(nsIDOMEvent event) {
+
+ }
+
+ public void handleEvent(nsIDOMEvent event) {
+ if (XulRunnerConstants.EVENT_NAME_MOUSEMOVE.equals(event.getType())) {
+ mouseMove(event);
+ }
+ }
+
+ public nsISupports queryInterface(String aIID) {
+ if (aIID.equals(nsIDOMEventListener.NS_IDOMEVENTLISTENER_IID)) {
+ return this;
+ } // if
+
+ return Mozilla.queryInterface(this, aIID);
+ }
+
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerConstants.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerConstants.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerConstants.java 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.vpe.xulrunner.editor;
+
+/**
+ * @author A. Yukhovich
+ *
+ */
+public class XulRunnerConstants {
+ /** HTML tags */
+
+ /** HTML_TAG_SPAN */
+ public static final String HTML_TAG_SPAN = "span";
+
+
+ /** HTML attributes */
+
+ /** HTML_ATTR_CLASS */
+ public static final String HTML_ATTR_CLASS = "class";
+
+ /** HTML_ATTR_ANONLOCATION */
+ public static final String HTML_ATTR_ANONLOCATION = "anonlocation";
+
+
+ /** HTML_ATTR_LEFT */
+ public static final String HTML_ATTR_LEFT = "left";
+
+ /** HTML_ATTR_TOP */
+ public static final String HTML_ATTR_TOP = "top";
+
+ /** HTML_ATTR_WIDTH */
+ public static final String HTML_ATTR_WIDTH = "width";
+
+ /** HTML_ATTR_HEIGHT */
+ public static final String HTML_ATTR_HEIGHT = "height";
+
+ /** HTML values */
+
+ /** HTML_VALUE_HIDDEN */
+ public static final String HTML_VALUE_HIDDEN = "hidden";
+
+ /** HTML_VALUE_TRUE */
+ public static final String HTML_VALUE_TRUE = "true";
+
+ /** HTML_VALUE_FALSE */
+ public static final String HTML_VALUE_FALSE = "false";
+
+ /** EVENT NAMES */
+
+ /** EVENT_NAME_MOUSEDOWN */
+ public static final String EVENT_NAME_MOUSEDOWN = "mousedown";
+
+ /** EVENT_NAME_MOUSEUP */
+ public static final String EVENT_NAME_MOUSEUP = "mouseup";
+
+ /** EVENT_NAME_MOUSEMOVE */
+ public static final String EVENT_NAME_MOUSEMOVE = "mousemove";
+
+ /** */
+
+ /** STRING_MOZ_ACTIVATED */
+ public static final String STRING_MOZ_ACTIVATED = "_moz_activated";
+
+ /** STRING_MOZ_ANONCLASS */
+ public static final String STRING_MOZ_ANONCLASS = "_moz_anonclass";
+
+ /** VPE_CLASSNAME_MOZ_RESIZER */
+ public static final String VPE_CLASSNAME_MOZ_RESIZER = "mozResizer";
+
+ /** VPE_CLASS_NAME_MOZ_RESIZING_SHADOW */
+ public static final String VPE_CLASS_NAME_MOZ_RESIZING_SHADOW = "mozResizingShadow";
+
+
+
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,513 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.vpe.xulrunner.editor;
+
+import java.util.regex.Pattern;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.jboss.tools.vpe.xulrunner.BrowserPlugin;
+import org.jboss.tools.vpe.xulrunner.XPCOM;
+import org.jboss.tools.vpe.xulrunner.XulRunnerException;
+import org.jboss.tools.vpe.xulrunner.browser.XulRunnerBrowser;
+import org.mozilla.interfaces.inIFlasher;
+import org.mozilla.interfaces.nsIBaseWindow;
+import org.mozilla.interfaces.nsIClipboardDragDropHookList;
+import org.mozilla.interfaces.nsIComponentManager;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMDocumentRange;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMRange;
+import org.mozilla.interfaces.nsIDOMWindow;
+import org.mozilla.interfaces.nsIDocShell;
+import org.mozilla.interfaces.nsIDragService;
+import org.mozilla.interfaces.nsIDragSession;
+import org.mozilla.interfaces.nsIInterfaceRequestor;
+import org.mozilla.interfaces.nsISelection;
+import org.mozilla.interfaces.nsIServiceManager;
+import org.mozilla.interfaces.nsISupports;
+import org.mozilla.interfaces.nsITransferable;
+import org.mozilla.xpcom.Mozilla;
+import org.mozilla.xpcom.XPCOMException;
+
+/**
+ * @author Sergey Vasilyev (svasilyev(a)exadel.com)
+ *
+ */
+public class XulRunnerEditor extends XulRunnerBrowser {
+ /** IVpeResizeListener */
+ private IVpeResizeListener resizeListener;
+
+ /** IXulRunnerVpeResizer */
+ private IXulRunnerVpeResizer xulRunnerVpeResizer;
+
+ /**
+ * color which used for highlight elements which user can see
+ */
+ public static final String flasherVisialElementColor = "blue";
+
+ /**
+ * color which used for highlight parent elements for elements which user
+ * can't see.
+ */
+ public static final String flasherHiddentElementColor = "red";
+
+ /**
+ * Contains name of attribute for inIFLasher drawing
+ */
+ public static String VPEFLASHERCOLORATTRIBUTE="vpeFlasherColorAttribute";
+
+ public static final String TRANS_FLAVOR_kHTMLMime = "text/html";
+ public static final String TRANS_FLAVOR_kURLDataMime = "text/x-moz-url-data";
+ public static final String TRANS_FLAVOR_kFileMime = "application/x-moz-file";
+ public static final String TRANS_FLAVOR_kURLMime = "text/x-moz-url";
+ public static final String TRANS_FLAVOR_kUnicodeMime = "text/unicode";
+ public static final String TRANS_FLAVOR_kNativeHTMLMime = "application/x-moz-nativehtml";
+
+ /**
+ * xpcom flasher component which used to draw lines
+ */
+ private inIFlasher iFlasher;
+ private nsIDocShell docShell = null;
+
+ /**
+ * RegExp for find expression 'display : none' in style string
+ */
+ private static final Pattern PATTERN = Pattern.compile(".*\\s*(display)\\s*:\\s*(none)\\s*;.*",Pattern.CASE_INSENSITIVE+Pattern.DOTALL);
+
+ /**
+ * Contains attribute name for style
+ */
+ private static final String STYLE_ATTR="style";
+
+ private nsIDOMElement lastSelectedElement;
+ private int lastResizerConstrains;
+ /**
+ * Scroll selection into view flag
+ */
+ private boolean scrollRegtangleFlag = false;
+
+ /**
+ * @param parent
+ * @throws XulRunnerException
+ */
+ public XulRunnerEditor(Composite parent) throws XulRunnerException {
+ super(parent);
+
+ Listener eventListenet = new Listener() {
+
+ public void handleEvent(Event event) {
+ Display.getCurrent().asyncExec(new Thread(){
+ public void run(){
+ showSelectionRectangle();
+ }
+ });
+ }};
+// addListener(SWT.Activate, eventListenet);
+ addListener(SWT.Paint, eventListenet);
+ //Commented by Max Areshkau (bug on Mac OS X10.4
+ //when switch from visual to preview selection rectangle doen't disappear
+// addListener(SWT.Resize, eventListenet);
+ addListener(SWT.Show, eventListenet);
+ addListener(SWT.FocusIn, eventListenet);
+ //Commented by Max Areshkau (bug on Mac OS X10.4
+ //when switch from visual to preview selection rectangle doen't disappear
+// addListener(SWT.FocusOut, eventListenet);
+ addListener(SWT.Selection, eventListenet);
+ addListener(SWT.Paint, eventListenet);
+
+ resizeListener = new IVpeResizeListener() {
+ public void onEndResizing(int usedResizeMarkerHandle, int top,
+ int left, int width, int height,
+ nsIDOMElement resizedDomElement) {
+ endResizing(usedResizeMarkerHandle, top, left, width, height, resizedDomElement);
+ }
+
+ public nsISupports queryInterface(String uuid) {
+ return null;
+ }
+ };
+
+
+ }
+
+ public boolean isMozillaDragFlavor() {
+
+ nsIDragSession dragSession = getCurrentDragSession();
+ if (dragSession != null) {
+ nsITransferable transferable = createTransferable();
+ if (transferable != null) {
+// transferable.flavorsTransferableCanImport();
+
+ transferable.addDataFlavor(TRANS_FLAVOR_kURLDataMime);
+ transferable.addDataFlavor(TRANS_FLAVOR_kFileMime);
+ transferable.addDataFlavor(TRANS_FLAVOR_kURLMime);
+ transferable.addDataFlavor(TRANS_FLAVOR_kUnicodeMime);
+ dragSession.getData(transferable, 0);
+
+// transferable.flavorsTransferableCanImport();
+ String[] flavors = new String[] {null};
+ nsISupports[] data = new nsISupports[] {null};
+ long[] length = new long[] {0};
+ transferable.getAnyTransferData(flavors, data, length);
+
+ return length[0] > 0;
+ }
+ }
+ return false;
+ }
+
+ public void onElementResize(nsIDOMElement element, int handle, int top, int left, int width, int height) {
+ }
+
+ public void onLoadWindow() {
+ if (getIXulRunnerVpeResizer() != null) {
+ getIXulRunnerVpeResizer().init(getDOMDocument());
+ getIXulRunnerVpeResizer().addResizeListener(resizeListener);
+ }
+
+ }
+
+ public nsIDragSession getCurrentDragSession() {
+ nsIServiceManager serviceManager = getServiceManager();
+ nsIDragService dragService = (nsIDragService) serviceManager.getServiceByContractID(XPCOM.NS_DRAGSERVICE_CONTRACTID, nsIDragService.NS_IDRAGSERVICE_IID);
+
+ return dragService.getCurrentSession();
+ }
+
+ public nsIClipboardDragDropHookList getClipboardDragDropHookList() {
+ nsIDocShell docShell = getDocShell();
+
+ if (docShell != null) {
+ nsIClipboardDragDropHookList hookList = (nsIClipboardDragDropHookList) docShell.queryInterface(nsIClipboardDragDropHookList.NS_ICLIPBOARDDRAGDROPHOOKLIST_IID);
+ return hookList;
+ }
+ return null;
+ }
+
+ public nsIDocShell getDocShell() {
+ if (docShell == null) {
+ nsIInterfaceRequestor interfaceRequestor = (nsIInterfaceRequestor) getWebBrowser().queryInterface(nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID);
+ docShell = (nsIDocShell) interfaceRequestor.getInterface(nsIDocShell.NS_IDOCSHELL_IID);
+ }
+
+ return docShell;
+ }
+
+ public nsIDOMDocument getDOMDocument() {
+ nsIDOMWindow domWindow = getWebBrowser().getContentDOMWindow();
+ return domWindow.getDocument();
+ }
+
+ public nsIDOMDocumentRange getDOMDocumentRange() {
+ return (nsIDOMDocumentRange) getDOMDocument().queryInterface(nsIDOMDocumentRange.NS_IDOMDOCUMENTRANGE_IID);
+ }
+
+ public nsIDOMRange createDOMRange() {
+ return getDOMDocumentRange().createRange();
+ }
+
+ public void showDragCaret(nsIDOMNode node, long offcet) {
+ // TODO Sergey Vasilyev figure out with caret
+ System.out.println("Show drag caret for " + node.getNodeName() + ":" + offcet);
+ }
+
+ public void hideDragCaret() {
+ // TODO Sergey Vasilyev figure out with caret
+ System.out.println("Hide drag caret");
+ }
+
+ public nsITransferable createTransferable() {
+ nsIComponentManager componentManager = getComponentManager();
+ return (nsITransferable) componentManager.createInstanceByContractID(XPCOM.NS_TRANSFERABLE_CONTRACTID, this, nsITransferable.NS_ITRANSFERABLE_IID);
+ }
+
+ /**
+ * Returns selection controller which used in selection functionality
+ * @return
+ */
+ public nsISelection getSelection() {
+
+ nsIDOMWindow domWindow = getWebBrowser().getContentDOMWindow();
+ nsISelection selection = domWindow.getSelection();
+ return selection;
+ }
+
+ /**
+ * Function created to restore functionality of MozillaBrowser
+ * @return
+ */
+ public nsIDOMElement getLastSelectedElement() {
+
+ return lastSelectedElement;
+ }
+ /**
+ * Function created to restore functionality of MozillaBrowser
+ * @return
+ */
+ private void setLastSelectedElement(nsIDOMElement lastSelectedElement) {
+ this.lastSelectedElement = lastSelectedElement;
+ }
+
+ /**
+ * Draws rectangle around the element.
+ * @param element
+ * @param resizerConstrains
+ * @param scroll
+ */
+ public void setSelectionRectangle(nsIDOMElement element, int resizerConstrains, boolean scroll) {
+ if (getIFlasher() == null) {
+
+ return;
+ }
+ if (getLastSelectedElement() != null) {
+
+ scrollRegtangleFlag = scroll && element != null;
+
+ if(checkVisability(getLastSelectedElement())){
+
+ if((getLastSelectedElement().getAttribute(VPEFLASHERCOLORATTRIBUTE)==null)||
+ (!getLastSelectedElement().getAttribute(VPEFLASHERCOLORATTRIBUTE).equals(flasherHiddentElementColor))) {
+
+ getIFlasher().setColor(flasherVisialElementColor);
+ } else{
+ getIFlasher().setColor(flasherHiddentElementColor);
+ }
+
+ getIFlasher().repaintElement(getLastSelectedElement());
+
+ }else {
+
+ getIFlasher().setColor(flasherHiddentElementColor);
+ nsIDOMElement domElement = findVisbleParentElement(getLastSelectedElement());
+
+ if(domElement!=null) {
+
+ getIFlasher().repaintElement(domElement);
+ }
+
+ }
+
+ } else if (element != null) {
+
+ if (scroll) {
+ scrollToElement(element);
+ scrollRegtangleFlag = true;
+ }
+ if(checkVisability(element)){
+
+
+ if((element.getAttribute(VPEFLASHERCOLORATTRIBUTE)==null)||
+ (!element.getAttribute(VPEFLASHERCOLORATTRIBUTE).equals(flasherHiddentElementColor))) {
+
+ getIFlasher().setColor(flasherVisialElementColor);
+ }else {
+ getIFlasher().setColor(flasherHiddentElementColor);
+ }
+ getIFlasher().drawElementOutline(element);
+ }else {
+
+ getIFlasher().setColor(flasherHiddentElementColor);
+ nsIDOMElement domElement = findVisbleParentElement(element);
+
+ if(domElement!=null) {
+
+ getIFlasher().drawElementOutline(domElement);
+ }
+ }
+
+
+ }
+
+ if (xulRunnerVpeResizer != null) {
+ if (element != null && resizerConstrains != 0) {
+ xulRunnerVpeResizer.show(element, resizerConstrains);
+ } else {
+ xulRunnerVpeResizer.hide();
+ }
+ }
+
+ setLastSelectedElement(element);
+ lastResizerConstrains = resizerConstrains;
+ }
+
+
+ /**
+ * @return the iFlasher
+ */
+ private inIFlasher getIFlasher() {
+
+ if(iFlasher==null) {
+ nsIServiceManager serviceManager = Mozilla.getInstance().getServiceManager();
+ iFlasher = (inIFlasher) serviceManager.getServiceByContractID(XPCOM.IN_FLASHER_CONTRACTID, inIFlasher.INIFLASHER_IID);
+ iFlasher.setThickness(2);
+ }
+ return iFlasher;
+ }
+
+
+ private IXulRunnerVpeResizer getIXulRunnerVpeResizer() {
+
+ if (xulRunnerVpeResizer==null) {
+ xulRunnerVpeResizer = new XulRunnerVpeResizer();
+ }
+ return xulRunnerVpeResizer;
+ }
+
+
+
+ /**Function created for checking if user can see element or not.
+ * Element doesn't shows in VPE if it's has 'display:none;' attribute in style.
+ *
+ * @param node for checking it's visability
+ * @param iFlasher flasher which used for drawning border for elements adn in
+ * which was setted color in depends of visability of element
+ *
+ * @return false for hiddent elements and true for visble elements
+ */
+ private boolean checkVisability(nsIDOMNode node){
+
+ nsIDOMElement domElement;
+ try{
+
+ domElement = (nsIDOMElement) node.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ } catch(XPCOMException exception) {
+ //if we can cast it's is invisible elenebt
+ return false;
+ }
+
+ //TODO add check not inline styles attribute such as styleclass
+ String inlineStyle = domElement.getAttribute(STYLE_ATTR);
+
+ return inlineStyle==null?true:!PATTERN.matcher(inlineStyle).matches();
+ }
+
+ /**
+ * Finds visible nearest visible node for hidden node
+ *
+ * @param element
+ *
+ * @return nearest visible node or null if can't find
+ */
+ private nsIDOMElement findVisbleParentElement(nsIDOMElement element) {
+
+ nsIDOMElement parentElement;
+
+ try {
+
+ parentElement = (nsIDOMElement) element.getParentNode().queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ } catch (XPCOMException ex) {
+ // if parent node isn't nsIDOMElement just return null;
+ return null;
+ }
+ while(parentElement!=null&&!checkVisability(parentElement)) {
+ if(checkVisability(parentElement)) {
+
+ return parentElement;
+ }else {
+
+ parentElement=(nsIDOMElement) parentElement.getParentNode() ;
+ }
+ }
+ return parentElement;
+ }
+
+ /**
+ * @param usedHandle
+ * @param newTop
+ * @param newLeft
+ * @param newWidth
+ * @param newHeight
+ * @param aResizedObject
+ */
+ private void endResizing(int usedHandle, int newTop, int newLeft, int newWidth, int newHeight, nsIDOMElement aResizedObject) {
+ onElementResize(aResizedObject, usedHandle, newTop, newLeft, newWidth, newHeight);
+ }
+
+ /**
+ *
+ */
+ public void showResizer() {
+ if (xulRunnerVpeResizer != null && lastSelectedElement != null && lastResizerConstrains != 0) {
+ xulRunnerVpeResizer.show(lastSelectedElement, lastResizerConstrains);
+ }
+ }
+
+ /**
+ * Hide resizer markers
+ */
+ public void hideResizer() {
+ if(xulRunnerVpeResizer != null) {
+ xulRunnerVpeResizer.hide();
+ }
+ }
+
+ public void showSelectionRectangle() {
+
+// ((nsIBaseWindow)getWebBrowser().queryInterface(nsIBaseWindow.NS_IBASEWINDOW_IID)).repaint(false);
+
+ if (getIFlasher() != null && getLastSelectedElement() != null) {
+ if (scrollRegtangleFlag) {
+ scrollRegtangleFlag = false;
+
+ scrollToElement(getLastSelectedElement());
+ }
+ //checks visability of element
+ if(checkVisability(getLastSelectedElement())){
+
+ if((getLastSelectedElement().getAttribute(VPEFLASHERCOLORATTRIBUTE)==null)||
+ (!getLastSelectedElement().getAttribute(VPEFLASHERCOLORATTRIBUTE).equals(flasherHiddentElementColor))) {
+
+ getIFlasher().setColor(flasherVisialElementColor);
+ }else{
+
+ getIFlasher().setColor(flasherHiddentElementColor);
+ }
+
+ getIFlasher().drawElementOutline(getLastSelectedElement());
+ }else {
+
+ getIFlasher().setColor(flasherHiddentElementColor);
+ nsIDOMElement domElement = findVisbleParentElement(getLastSelectedElement());
+
+ if(domElement!=null) {
+ getIFlasher().drawElementOutline(domElement);
+ }
+ }
+ } else if(getIFlasher()!=null&&Platform.getOSArch().equals(Platform.OS_MACOSX)){
+ //Max Areshkau (bug on Mac OS X, when we switch to preview from other view, selection rectangle doesn't disappear
+ //TODO Max Areshkau (may be exist passability not draw selection on resize event when we switches to other view)
+ try {
+ ((nsIBaseWindow)getWebBrowser().queryInterface(nsIBaseWindow.NS_IBASEWINDOW_IID)).repaint(true);
+ } catch(XPCOMException ex) {
+ //just ignore its
+ BrowserPlugin.getDefault().logInfo("repaint failed", ex);
+ }
+ }
+ }
+ /**
+ * Scrools viiew to some elements
+ * @param element -element to which we should scroll
+ */
+ private void scrollToElement(nsIDOMElement element){
+
+ getIFlasher().scrollElementIntoView(element);
+ }
+}
+
+
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeResizer.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeResizer.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeResizer.java 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,794 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.vpe.xulrunner.editor;
+
+
+import java.util.ArrayList;
+import org.eclipse.swt.graphics.Rectangle;
+import org.mozilla.interfaces.nsIDOMCSSStyleDeclaration;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMElementCSSInlineStyle;
+import org.mozilla.interfaces.nsIDOMEvent;
+import org.mozilla.interfaces.nsIDOMEventListener;
+import org.mozilla.interfaces.nsIDOMEventTarget;
+import org.mozilla.interfaces.nsIDOMHTMLDocument;
+import org.mozilla.interfaces.nsIDOMHTMLElement;
+import org.mozilla.interfaces.nsIDOMMouseEvent;
+import org.mozilla.interfaces.nsIDOMNode;
+
+/**
+ * IXulRunnerVpeResizer implementation
+ * @author A. Yukhovich
+ */
+public class XulRunnerVpeResizer implements IXulRunnerVpeResizer {
+ /** COEFFICIENT_TYPE */
+ enum COEFFICIENT_TYPE { X, Y, WIDTH, HEIGHT };
+
+
+ /** RESIZER_MARKER_STRING_TOPLEFT */
+ final static private String RESIZER_MARKER_STRING_TOPLEFT = "nw";
+
+ /** RESIZER_MARKER_STRING_TOP */
+ final static private String RESIZER_MARKER_STRING_TOP = "n";
+
+ /** RESIZER_MARKER_STRING_TOPRIGHT */
+ final static private String RESIZER_MARKER_STRING_TOPRIGHT = "ne";
+
+ /** RESIZER_MARKER_STRING_LEFT */
+ final static private String RESIZER_MARKER_STRING_LEFT = "w";
+
+ /** RESIZER_MARKER_STRING_BOTTOMLEFT */
+ final static private String RESIZER_MARKER_STRING_RIGHT = "e";
+
+ /** RESIZER_MARKER_STRING_BOTTOMLEFT */
+ final static private String RESIZER_MARKER_STRING_BOTTOMLEFT = "sw";
+
+ /** RESIZER_MARKER_STRING_BOTTOM */
+ final static private String RESIZER_MARKER_STRING_BOTTOM = "s";
+
+ /** RESIZER_MARKER_STRING_BOTTOMRIGHT */
+ final static private String RESIZER_MARKER_STRING_BOTTOMRIGHT = "se";
+
+ /** MAX_SIZE */
+ final static private int MAX_SIZE = 20000000;
+
+
+ nsIDOMEventListener mouseListener;
+ nsIDOMEventListener mouseMotionListener;
+
+
+ private ArrayList<IVpeResizeListener> objectResizeEventListeners = new ArrayList<IVpeResizeListener>();
+
+ private boolean isResizing;
+ private int originalX;
+ private int originalY;
+
+ /** bit-mask of used resize marker */
+ private int usedResizeMarker;
+
+ private int incrementFactorX;
+ private int incrementFactorY;
+ private int incrementFactorWidth;
+ private int incrementFactorHeight;
+
+
+ /** resizingObject */
+ private nsIDOMElement resizingObject;
+
+ /** resizingShadow */
+ private nsIDOMElement resizingShadow;
+
+ /** domDocument */
+ private nsIDOMDocument domDocument;
+
+ private nsIDOMElement activeHandle;
+
+ private Rectangle elementBounds;
+
+ /** resizer marker top-left */
+ private nsIDOMElement markerTopLeft = null;
+
+ /** resizer marker top */
+ private nsIDOMElement markerTop = null;
+
+ /** resizer marker top-right */
+ private nsIDOMElement markerTopRight = null;
+
+ /** resizer marker left */
+ private nsIDOMElement markerLeft = null;
+
+ /** resizer marker right */
+ private nsIDOMElement markerRight = null;
+
+ /** resizer marker bottom */
+ private nsIDOMElement markerBottom = null;
+
+ /** resizer marker bottom-left */
+ private nsIDOMElement markerBottomLeft = null;
+
+ /** resizer marker bottom-right */
+ private nsIDOMElement markerBottomRight = null;
+
+
+ /**
+ *
+ * @param domDocument
+ */
+ public void init(nsIDOMDocument domDocument)
+ {
+
+ this.domDocument = domDocument;
+
+ mouseListener = new VpeResizerMouseListener(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.vpe.mozilla.resizer.IVpeResizer#show(org.mozilla.interfaces.nsIDOMElement, int)
+ */
+ public void show(nsIDOMElement domElement, int resizers) {
+
+ if ( resizingObject != null ) {
+ hide();
+ }
+
+ resizingObject = domElement;
+
+ elementBounds = XulRunnerVpeUtils.getElementBounds(domElement);
+
+ if ((elementBounds.width <= 0) ||
+ (elementBounds.width > MAX_SIZE) ||
+ (elementBounds.height <= 0) ||
+ (elementBounds.height > MAX_SIZE)) return;
+
+ nsIDOMElement bodyElement = getRootElement();
+
+ if (bodyElement == null ) return;
+
+ if ((resizers & RESIZER_MARKER_TOPLEFT) == RESIZER_MARKER_TOPLEFT) {
+ markerTopLeft = createResizer( RESIZER_MARKER_STRING_TOPLEFT, bodyElement);
+ if (markerTopLeft == null) {
+ return ;
+ }
+ }
+
+ if ((resizers & RESIZER_MARKER_TOP) == RESIZER_MARKER_TOP) {
+ markerTop = createResizer( RESIZER_MARKER_STRING_TOP, bodyElement);
+ if (markerTop == null) {
+ return ;
+ }
+ }
+
+ if ((resizers & RESIZER_MARKER_TOPRIGHT) == RESIZER_MARKER_TOPRIGHT) {
+ markerTopRight = createResizer(RESIZER_MARKER_STRING_TOPRIGHT, bodyElement);
+ if (markerTopRight == null) {
+ return ;
+ }
+ }
+
+ if ((resizers & RESIZER_MARKER_LEFT) == RESIZER_MARKER_LEFT) {
+ markerLeft = createResizer(RESIZER_MARKER_STRING_LEFT, bodyElement);
+ if (markerLeft == null) {
+ return ;
+ }
+ }
+
+ if ((resizers & RESIZER_MARKER_RIGHT) == RESIZER_MARKER_RIGHT) {
+ markerRight = createResizer(RESIZER_MARKER_STRING_RIGHT, bodyElement);
+ if (markerRight == null) {
+ return ;
+ }
+ }
+
+ if ((resizers & RESIZER_MARKER_BOTTOMLEFT) == RESIZER_MARKER_BOTTOMLEFT) {
+ markerBottomLeft = createResizer(RESIZER_MARKER_STRING_BOTTOMLEFT, bodyElement);
+ if (markerBottomLeft == null) {
+ return ;
+ }
+ }
+
+ if ((resizers & RESIZER_MARKER_BOTTOM) == RESIZER_MARKER_BOTTOM) {
+ markerBottom = createResizer(RESIZER_MARKER_STRING_BOTTOM, bodyElement);
+ if (markerBottom == null) {
+ return ;
+ }
+ }
+
+ if ((resizers & RESIZER_MARKER_BOTTOMRIGHT) == RESIZER_MARKER_BOTTOMRIGHT) {
+ markerBottomRight = createResizer(RESIZER_MARKER_STRING_BOTTOMRIGHT, bodyElement);
+ if (markerBottomRight == null) {
+ return ;
+ }
+ }
+
+ setAllResizersPosition();
+
+ resizingShadow = createShadow(bodyElement, resizingObject);
+
+ setShadowPosition(resizingShadow, elementBounds.x, elementBounds.y);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.jboss.vpe.mozilla.resizer.IVpeResizer#hide()
+ */
+ public void hide() {
+ nsIDOMElement bodyElement;
+
+ bodyElement = getRootElement();
+ if ( bodyElement == null ) {
+ return;
+ }
+
+ nsIDOMNode parentNode = (nsIDOMNode) bodyElement.queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
+
+ if ( parentNode == null) {
+ return;
+ }
+
+ if ( markerTopLeft != null) {
+ parentNode.removeChild(markerTopLeft);
+ }
+
+ if ( markerTop != null) {
+ parentNode.removeChild(markerTop);
+ }
+
+
+ if ( markerTopRight != null) {
+ parentNode.removeChild(markerTopRight);
+ }
+
+ if ( markerLeft != null) {
+ parentNode.removeChild(markerLeft);
+ }
+
+ if ( markerRight != null) {
+ parentNode.removeChild(markerRight);
+ }
+
+ if ( markerBottomLeft != null) {
+ parentNode.removeChild(markerBottomLeft);
+ }
+
+ if ( markerBottom != null) {
+ parentNode.removeChild(markerBottom);
+ }
+
+ if ( markerBottomRight != null) {
+ parentNode.removeChild(markerBottomRight);
+ }
+
+
+ if ( resizingShadow != null ) {
+ parentNode.removeChild(resizingShadow);
+ }
+
+ markerBottom = null;
+ markerTop = null;
+ markerLeft = null;
+ markerRight = null;
+ markerBottomRight = null;
+ markerBottomLeft = null;
+ markerTopRight = null;
+ markerTopLeft = null;
+
+ resizingShadow = null;
+ resizingObject = null;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.jboss.vpe.mozilla.resizer.IVpeResizer#mouseDown(int, int, org.mozilla.interfaces.nsIDOMElement)
+ */
+ public void mouseDown(int clientX, int clientY, nsIDOMElement domElement) {
+
+
+ if ( domElement != null ) {
+
+ boolean isAnonElement = domElement.hasAttribute(XulRunnerConstants.STRING_MOZ_ANONCLASS);
+
+ if (isAnonElement) {
+ String anonclass = domElement.getAttribute(XulRunnerConstants.STRING_MOZ_ANONCLASS);
+
+ if ( anonclass != null ) {
+ if ( anonclass.equals(XulRunnerConstants.VPE_CLASSNAME_MOZ_RESIZER) ) {
+ originalX = clientX;
+ originalY = clientY;
+ startResizing(domElement);
+ } // if
+ } // if
+ } // if
+ } // if
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.jboss.vpe.mozilla.resizer.IVpeResizer#mouseMove(org.mozilla.interfaces.nsIDOMEvent)
+ */
+ public void mouseMove(nsIDOMEvent event) {
+ if (isResizing) {
+ nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent)event.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+ int clientX, clientY;
+
+ clientX = mouseEvent.getClientX();
+ clientY = mouseEvent.getClientY();
+
+ int newX = getNewResizingX(clientX, clientY);
+ int newY = getNewResizingY(clientX, clientY);
+ int newWidth = getNewResizingWidth(clientX, clientY);
+ int newHeight = getNewResizingHeight(clientX, clientY);
+
+ setStylePropertyPixels(resizingShadow, XulRunnerConstants.HTML_ATTR_LEFT, newX);
+ setStylePropertyPixels(resizingShadow, XulRunnerConstants.HTML_ATTR_TOP, newY);
+ setStylePropertyPixels(resizingShadow, XulRunnerConstants.HTML_ATTR_WIDTH, newWidth);
+ setStylePropertyPixels(resizingShadow, XulRunnerConstants.HTML_ATTR_HEIGHT, newHeight);
+ } // if
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.jboss.vpe.mozilla.resizer.IVpeResizer#mouseUp(int, int, org.mozilla.interfaces.nsIDOMElement)
+ */
+ public void mouseUp(int aX, int aY, nsIDOMElement target) {
+ if (isResizing) {
+ isResizing = false;
+
+
+ hideShadow();
+ endResizing(aX, aY);
+
+ nsIDOMEventTarget erP = getDOMEventTarget();
+
+ if (erP != null) {
+ erP.removeEventListener(XulRunnerConstants.EVENT_NAME_MOUSEMOVE, mouseMotionListener, true);
+ erP.removeEventListener(XulRunnerConstants.EVENT_NAME_MOUSEUP, mouseListener, true);
+ mouseMotionListener = null;
+ }
+ }
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.jboss.vpe.mozilla.resizer.IVpeResizer#addResizeListener(org.jboss.vpe.mozilla.resizer.IVpeResizeListener)
+ */
+ public void addResizeListener(IVpeResizeListener listener) {
+ if ( (objectResizeEventListeners.size() != 0 ) &&
+ ( objectResizeEventListeners.indexOf(listener) != -1)) {
+ return;
+ }
+ objectResizeEventListeners.add(listener);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.jboss.vpe.mozilla.resizer.IVpeResizer#removeResizeListener(org.jboss.vpe.mozilla.resizer.IVpeResizeListener)
+ */
+ public void removeResizeListener(IVpeResizeListener listener) {
+ if ( (objectResizeEventListeners.size() == 0 ) ||
+ ( objectResizeEventListeners.indexOf(listener) == -1)) {
+ return;
+ }
+ objectResizeEventListeners.remove(listener);
+ }
+
+ /**
+ * Setting a position of shadow
+ * @param shadowElement
+ * @param aOriginalObjectX
+ * @param aOriginalObjectY
+ */
+ private void setShadowPosition(nsIDOMElement shadowElement, int aOriginalObjectX, int aOriginalObjectY) {
+ setAnonymousElementPosition(aOriginalObjectX, aOriginalObjectY, shadowElement);
+ }
+
+
+ /**
+ * create a anonymous dom-element
+ *
+ * @param aTag
+ * a tag of dom element
+ * @param aParentNode
+ * @param aAnonClass
+ * @param isCreatedHidden
+ * @return
+ */
+ private nsIDOMElement createAnonymousElement(String aTag, nsIDOMNode aParentNode, String aAnonClass, boolean isCreatedHidden) {
+ nsIDOMElement returnElement = null;
+
+ returnElement = domDocument.createElement(aTag);
+
+ // add the "hidden" class if needed
+ if (isCreatedHidden) {
+ returnElement.setAttribute(XulRunnerConstants.HTML_ATTR_CLASS, XulRunnerConstants.HTML_VALUE_HIDDEN);
+ }
+
+ // add an _moz_anonclass attribute if needed
+ if ( aAnonClass.length() != 0 ) {
+ returnElement.setAttribute(XulRunnerConstants.STRING_MOZ_ANONCLASS, aAnonClass);
+ }
+
+ aParentNode.appendChild(returnElement);
+
+ return returnElement;
+ }
+
+ /**
+ *
+ * @param parentNode
+ * @param originalObject
+ * @return
+ */
+ private nsIDOMElement createShadow(nsIDOMNode parentNode, nsIDOMElement originalObject) {
+ nsIDOMElement returnElement = null;
+
+ returnElement = createAnonymousElement(XulRunnerConstants.HTML_TAG_SPAN, parentNode, XulRunnerConstants.VPE_CLASS_NAME_MOZ_RESIZING_SHADOW, true );
+
+ return returnElement;
+ }
+
+ /**
+ *
+ * @param domElement
+ */
+ private void startResizing(nsIDOMElement domElement) {
+ isResizing = true;
+
+ activeHandle = domElement;
+ activeHandle.setAttribute(XulRunnerConstants.STRING_MOZ_ACTIVATED, XulRunnerConstants.HTML_VALUE_TRUE);
+
+ String locationStr = activeHandle.getAttribute(XulRunnerConstants.HTML_ATTR_ANONLOCATION);
+
+ if (locationStr == null ) {
+ return;
+ }
+
+ if (locationStr.equals(RESIZER_MARKER_STRING_TOPLEFT)) {
+ usedResizeMarker = RESIZER_MARKER_TOPLEFT;
+ setResizeIncrements(1, 1, -1, -1, false);
+ } else if (locationStr.equals(RESIZER_MARKER_STRING_TOP)) {
+ usedResizeMarker = RESIZER_MARKER_TOP;
+ setResizeIncrements(0, 1, 0, -1, false);
+ } else if (locationStr.equals(RESIZER_MARKER_STRING_TOPRIGHT)) {
+ usedResizeMarker = RESIZER_MARKER_TOPRIGHT;
+ setResizeIncrements(0, 1, 1, -1, false);
+ } else if (locationStr.equals(RESIZER_MARKER_STRING_LEFT)) {
+ usedResizeMarker = RESIZER_MARKER_LEFT;
+ setResizeIncrements(1, 0, -1, 0, false);
+ } else if (locationStr.equals(RESIZER_MARKER_STRING_RIGHT)) {
+ usedResizeMarker = RESIZER_MARKER_RIGHT;
+ setResizeIncrements(0, 0, 1, 0, false);
+ } else if (locationStr.equals(RESIZER_MARKER_STRING_BOTTOMLEFT)) {
+ usedResizeMarker = RESIZER_MARKER_BOTTOMLEFT;
+ setResizeIncrements(1, 0, -1, 1, false);
+ } else if (locationStr.equals(RESIZER_MARKER_STRING_BOTTOM)) {
+ usedResizeMarker = RESIZER_MARKER_BOTTOM;
+ setResizeIncrements(0, 0, 0, 1, false);
+ } else if (locationStr.equals(RESIZER_MARKER_STRING_BOTTOMRIGHT)) {
+ usedResizeMarker = RESIZER_MARKER_BOTTOMRIGHT;
+ setResizeIncrements(0, 0, 1, 1, false);
+ }
+
+ // make the shadow appear
+ resizingShadow.removeAttribute(XulRunnerConstants.HTML_ATTR_CLASS);
+
+ // position it
+ setShadowPosition(resizingShadow, elementBounds.x, elementBounds.y);
+
+ setStylePropertyPixels(resizingShadow, XulRunnerConstants.HTML_ATTR_WIDTH, elementBounds.width );
+ setStylePropertyPixels(resizingShadow, XulRunnerConstants.HTML_ATTR_HEIGHT, elementBounds.height );
+
+
+ if (mouseMotionListener != null) {
+ return;
+ }
+
+ mouseMotionListener = new VpeResizerMouseMotionListener(this);
+ if ( mouseMotionListener == null ) {
+ return;
+ }
+
+ nsIDOMEventTarget eventTarget = getDOMEventTarget();
+
+ if ( eventTarget != null ) {
+ eventTarget.addEventListener(XulRunnerConstants.EVENT_NAME_MOUSEMOVE, mouseMotionListener, true);
+ eventTarget.addEventListener(XulRunnerConstants.EVENT_NAME_MOUSEUP, mouseListener, true);
+ }
+
+ return;
+ }
+
+ /**
+ * getting a nsIDOMEventTarget from nsIDOMDocument
+ * @return nsIDOMEventTarget from nsIDOMDocument
+ */
+ private nsIDOMEventTarget getDOMEventTarget() {
+
+ nsIDOMEventTarget eventTarget = (nsIDOMEventTarget) domDocument.queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
+ if (eventTarget == null) {
+ throw new RuntimeException("nsIDOMEventTarget is null");
+ }
+
+ return eventTarget;
+ }
+
+
+ /**
+ *
+ * @param aX
+ * @param aY
+ * @return
+ */
+ private int getNewResizingX(int aX, int aY) {
+ int resized = elementBounds.x+ getNewResizingIncrement(aX, aY, COEFFICIENT_TYPE.X) * incrementFactorX;
+ int max = elementBounds.x + elementBounds.width;
+ return Math.min(resized, max);
+ }
+
+ /**
+ *
+ * @param aX
+ * @param aY
+ * @return
+ */
+ private int getNewResizingY(int aX, int aY) {
+ int resized = elementBounds.y + getNewResizingIncrement(aX, aY, COEFFICIENT_TYPE.Y) * incrementFactorY;
+ int max = elementBounds.y + elementBounds.height;
+ return Math.min(resized, max);
+ }
+
+ /**
+ *
+ * @param aX
+ * @param aY
+ * @return
+ */
+ private int getNewResizingWidth(int aX, int aY) {
+ int resized = elementBounds.width + getNewResizingIncrement(aX, aY, COEFFICIENT_TYPE.WIDTH) * incrementFactorWidth;
+ return Math.max(resized, 1);
+ }
+
+ /**
+ *
+ * @param aX
+ * @param aY
+ * @return
+ */
+ private int getNewResizingHeight(int aX, int aY) {
+ int resized = elementBounds.height + getNewResizingIncrement(aX, aY, COEFFICIENT_TYPE.HEIGHT) * incrementFactorHeight;
+ return Math.max(resized, 1);
+ }
+
+ /**
+ *
+ * @param aX
+ * @param aY
+ * @param coefficient_type
+ * @return
+ */
+ private int getNewResizingIncrement(int aX, int aY, COEFFICIENT_TYPE coefficient_type) {
+ int result = 0;
+
+ switch (coefficient_type) {
+ case X:
+ case WIDTH:
+ result = aX - originalX;
+ break;
+ case Y:
+ case HEIGHT:
+ result = aY - originalY;
+ break;
+ }
+ return result;
+ }
+
+
+ /**
+ * Get root element
+ *
+ * @return root element
+ */
+ private nsIDOMElement getRootElement() {
+
+ nsIDOMElement bodyElement = null;
+
+ nsIDOMHTMLDocument htmlDocument = (nsIDOMHTMLDocument) domDocument.queryInterface(nsIDOMHTMLDocument.NS_IDOMHTMLDOCUMENT_IID);
+
+ if ( htmlDocument != null ) {
+ nsIDOMHTMLElement htmlBody = htmlDocument.getBody();
+
+ if ( htmlBody != null ) {
+ bodyElement = (nsIDOMElement) htmlBody.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ } // if
+ } // if
+
+ return bodyElement;
+ }
+
+ /**
+ * Create a new resizer element
+ * @param resizerMarkerString
+ * @param parentNode
+ * @return a new resizer element
+ */
+ private nsIDOMElement createResizer(String resizerMarkerString, nsIDOMNode parentNode) {
+ nsIDOMElement aNewResizer = createAnonymousElement(XulRunnerConstants.HTML_TAG_SPAN, parentNode, XulRunnerConstants.VPE_CLASSNAME_MOZ_RESIZER, false );
+
+ nsIDOMEventTarget evtTarget = (nsIDOMEventTarget) aNewResizer.queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
+
+ evtTarget.addEventListener(XulRunnerConstants.EVENT_NAME_MOUSEDOWN, mouseListener, true);
+
+ aNewResizer.setAttribute(XulRunnerConstants.HTML_ATTR_ANONLOCATION, resizerMarkerString);
+
+ return aNewResizer;
+ }
+
+
+ /**
+ * Set all positions of resizer's markers
+ */
+ private void setAllResizersPosition() {
+ int left = elementBounds.x;
+ int top = elementBounds.y;
+ int width = elementBounds.width;
+ int height = elementBounds.height;
+
+ int resizerWidth = 5;
+ int resizerHeight = 5;
+
+ int rw = (int)((resizerWidth + 1) / 2);
+ int rh = (int)((resizerHeight+ 1) / 2);
+
+ if (markerTopLeft != null) {
+ setAnonymousElementPosition(left-resizerWidth-2, top-resizerHeight-2, markerTopLeft);
+ }
+
+ if (markerTop != null) {
+ setAnonymousElementPosition(left+width/2-rw, top-resizerHeight-2, markerTop);
+ }
+
+ if (markerTopRight != null) {
+ setAnonymousElementPosition(left+width, top-resizerHeight-2, markerTopRight);
+ }
+
+ if (markerLeft != null) {
+ setAnonymousElementPosition(left-resizerWidth-2, top+height/2-rh, markerLeft);
+ }
+
+ if (markerRight != null) {
+ setAnonymousElementPosition(left+width, top+height/2-rh, markerRight);
+ }
+
+ if (markerBottomLeft != null) {
+ setAnonymousElementPosition(left-resizerWidth-2, top+height, markerBottomLeft);
+ }
+
+ if (markerBottom != null) {
+ setAnonymousElementPosition(left+width/2-rw, top+height, markerBottom);
+ }
+
+ if (markerBottomRight != null) {
+ setAnonymousElementPosition(left+width, top+height, markerBottomRight);
+ }
+
+ }
+
+ /**
+ *
+ * @param left
+ * @param top
+ * @param domElement
+ */
+ private void setAnonymousElementPosition(int left, int top,nsIDOMElement domElement) {
+ setStylePropertyPixels(domElement,XulRunnerConstants.HTML_ATTR_LEFT, left);
+ setStylePropertyPixels(domElement,XulRunnerConstants.HTML_ATTR_TOP, top);
+ }
+
+ /**
+ *
+ * @param aElement
+ * @param aProperty
+ * @param aValue
+ */
+ private void setStylePropertyPixels(nsIDOMElement aElement, String aProperty, int aValue) {
+ setStyle(aElement, aProperty, aValue + "px");
+ }
+
+ /**
+ *
+ * @param aX
+ * @param aY
+ * @param aW
+ * @param aH
+ * @param aPreserveRatio
+ */
+ private void setResizeIncrements(int aX, int aY, int aW, int aH, boolean aPreserveRatio) {
+ incrementFactorX = aX;
+ incrementFactorY = aY;
+ incrementFactorWidth = aW;
+ incrementFactorHeight = aH;
+ // mPreserveRatio = aPreserveRatio;
+ }
+
+
+ /**
+ * Set style for nsIDOMElement
+ * @param domElement
+ * @param cssPropertyName
+ * @param cssPropertyValue
+ */
+ private void setStyle(nsIDOMElement domElement, String cssPropertyName, String cssPropertyValue) {
+ nsIDOMElementCSSInlineStyle inlineStyles = (nsIDOMElementCSSInlineStyle) domElement.queryInterface(nsIDOMElementCSSInlineStyle.NS_IDOMELEMENTCSSINLINESTYLE_IID);
+
+ if ( inlineStyles == null) {
+ return;
+ }
+
+ nsIDOMCSSStyleDeclaration cssDecl = inlineStyles.getStyle();
+
+ if ( cssDecl == null) {
+ return;
+ }
+
+ if (cssPropertyValue.length() == 0 ) {
+ // an empty value means we have to remove the property
+ cssDecl.removeProperty(cssPropertyName);
+ } else {
+ // let's recreate the declaration as it was
+ String priority = cssDecl.getPropertyPriority(cssPropertyName);
+ cssDecl.setProperty(cssPropertyName, cssPropertyValue, priority);
+ }
+ }
+
+
+ /**
+ *
+ * @param aClientX
+ * @param aClientY
+ */
+ private void endResizing(int aClientX, int aClientY) {
+ if (resizingShadow == null) {
+ return;
+ }
+
+ if( activeHandle != null) {
+ activeHandle.removeAttribute(XulRunnerConstants.STRING_MOZ_ACTIVATED);
+ activeHandle = null;
+ }
+
+ int left = getNewResizingX(aClientX, aClientY);
+ int top = getNewResizingY(aClientX, aClientY);
+ int width = getNewResizingWidth(aClientX, aClientY);
+ int height = getNewResizingHeight(aClientX, aClientY);
+
+ if ( objectResizeEventListeners.size() != 0) {
+ for ( IVpeResizeListener resizeListener : objectResizeEventListeners ) {
+ resizeListener.onEndResizing(usedResizeMarker,top,left,width,height,resizingObject);
+ }
+ }
+
+ usedResizeMarker = 0;
+ }
+
+ /**
+ * Hide of shadow box
+ */
+ private void hideShadow() {
+ if (resizingShadow != null ) {
+ resizingShadow.setAttribute(XulRunnerConstants.HTML_ATTR_CLASS, XulRunnerConstants.HTML_VALUE_HIDDEN);
+ }
+ }
+
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeUtils.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeUtils.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeUtils.java 2007-10-16 16:19:53 UTC (rev 4251)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.vpe.xulrunner.editor;
+
+import org.eclipse.swt.graphics.Rectangle;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNSHTMLElement;
+import org.mozilla.xpcom.XPCOMException;
+
+/**
+ * @author A. Yukhovich
+ */
+public class XulRunnerVpeUtils {
+
+ /**
+ * @param domElement
+ * @return
+ */
+ static public Rectangle getElementBounds(nsIDOMElement domElement) {
+ try {
+ nsIDOMNSHTMLElement domNSHTMLElement = (nsIDOMNSHTMLElement) domElement.queryInterface(nsIDOMNSHTMLElement.NS_IDOMNSHTMLELEMENT_IID);
+ int offsetLeft = domNSHTMLElement.getOffsetLeft();
+ int offsetTop = domNSHTMLElement.getOffsetTop();
+ int width = domNSHTMLElement.getOffsetWidth();
+ int height = domNSHTMLElement.getOffsetHeight();
+
+ while (true) {
+ try {
+ if (domNSHTMLElement.getOffsetParent() == null) {
+ break;
+ }
+
+ domNSHTMLElement = (nsIDOMNSHTMLElement) domNSHTMLElement.getOffsetParent().queryInterface(nsIDOMNSHTMLElement.NS_IDOMNSHTMLELEMENT_IID);
+ offsetLeft += domNSHTMLElement.getOffsetLeft();
+ offsetTop += domNSHTMLElement.getOffsetTop();
+ } catch (XPCOMException ex) {
+ break;
+ }
+ }
+ return new Rectangle(offsetLeft, offsetTop, width, height);
+
+ } catch (XPCOMException xpcomException) {
+ return new Rectangle(0, 0, 0, 0);
+ }
+ }
+}
17 years, 3 months
JBoss Tools SVN: r4250 - trunk/vpe/plugins.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2007-10-16 12:19:17 -0400 (Tue, 16 Oct 2007)
New Revision: 4250
Added:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/
Log:
Sync with jbosstools_xulrunner branch
17 years, 3 months
JBoss Tools SVN: r4249 - tags.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2007-10-16 12:15:44 -0400 (Tue, 16 Oct 2007)
New Revision: 4249
Added:
tags/before_xulrunner/
Log:
State before XULRunner use in Visual Editor
Copied: tags/before_xulrunner (from rev 4248, trunk)
17 years, 3 months
JBoss Tools SVN: r4248 - branches.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-10-16 12:14:02 -0400 (Tue, 16 Oct 2007)
New Revision: 4248
Added:
branches/before_xulrunner/
Log:
before xulrunner tag
Copied: branches/before_xulrunner (from rev 4247, trunk)
17 years, 3 months
JBoss Tools SVN: r4247 - branches.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-10-16 12:13:50 -0400 (Tue, 16 Oct 2007)
New Revision: 4247
Removed:
branches/before_xulrunner/
Log:
Removed file/folder
17 years, 3 months
JBoss Tools SVN: r4246 - branches.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-10-16 12:12:51 -0400 (Tue, 16 Oct 2007)
New Revision: 4246
Added:
branches/before_xulrunner/
Log:
tag for before xulrunner
17 years, 3 months
JBoss Tools SVN: r4245 - in trunk/jst/plugins/org.jboss.tools.jst.web.debug.ui: images/xstudio/debug and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2007-10-16 12:10:59 -0400 (Tue, 16 Oct 2007)
New Revision: 4245
Removed:
trunk/jst/plugins/org.jboss.tools.jst.web.debug.ui/images/xstudio/debug/web_data_view.gif
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.debug.ui/plugin.xml
Log:
http://jira.jboss.com/jira/browse/JBIDE-1060 Removed Web Data View
Deleted: trunk/jst/plugins/org.jboss.tools.jst.web.debug.ui/images/xstudio/debug/web_data_view.gif
===================================================================
(Binary files differ)
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.debug.ui/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.debug.ui/plugin.xml 2007-10-16 15:36:32 UTC (rev 4244)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.debug.ui/plugin.xml 2007-10-16 16:10:59 UTC (rev 4245)
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>
-
<extension point="org.eclipse.ui.editorActions">
<editorContribution id="org.jboss.tools.jst.web.ui.jspEditorContribution" targetID="org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor">
<action actionID="RulerDoubleClick" class="org.jboss.tools.jst.web.debug.ui.internal.ToggleBreakpointActionDelegate" id="org.jboss.tools.jst.web.debug.ui.internal.ToggleBreakpointActionDelegate" label="Toggle Breakpoint">
@@ -16,22 +15,4 @@
<imageprovider class="org.jboss.tools.jst.web.debug.ui.internal.BreakpointImageProvider" id="org.jboss.tools.jst.web.debug.ui.breakpointImageProvider" markertype="org.jboss.tools.jst.web.debug.jspLineBreakpointMarker">
</imageprovider>
</extension>
- <extension point="org.eclipse.ui.views">
- <category id="org.eclipse.debug.ui" name="debug"/>
- <view category="org.eclipse.debug.ui" class="org.jboss.tools.jst.web.debug.ui.internal.views.xpl.WebDataView" icon="images/xstudio/debug/web_data_view.gif" id="org.jboss.tools.jst.web.debug.ui.internal.views.WebDataView" name="Web Data"/>
- </extension>
- <extension point="org.eclipse.ui.perspectiveExtensions">
- <perspectiveExtension targetID="org.eclipse.debug.ui.DebugPerspective">
- <perspectiveShortcut id="org.eclipse.debug.ui.DebugPerspective"/>
- </perspectiveExtension>
- <perspectiveExtension targetID="org.eclipse.debug.ui.DebugPerspective">
- <view closeable="true" id="org.jboss.tools.jst.web.debug.ui.internal.views.WebDataView" moveable="true" relationship="stack" relative="org.eclipse.debug.ui.VariableView" showTitle="true" standalone="true" visible="true"/>
- </perspectiveExtension>
- </extension>
-
- <extension point="org.eclipse.ui.preferencePages">
- <page category="org.jboss.tools.common.model.ui" class="org.jboss.tools.jst.web.debug.ui.internal.views.properties.WebDataPreferencePage" id="org.jboss.tools.jst.web.debug.ui.internal.views.properties.WebData" name="WebData">
- </page>
- </extension>
-
</plugin>
\ No newline at end of file
17 years, 3 months
JBoss Tools SVN: r4244 - trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-10-16 11:36:32 -0400 (Tue, 16 Oct 2007)
New Revision: 4244
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePage.java
Log:
JBIDE-982
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePage.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePage.java 2007-10-16 15:17:41 UTC (rev 4243)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePage.java 2007-10-16 15:36:32 UTC (rev 4244)
@@ -34,6 +34,7 @@
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.core.SeamPreferences;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.jboss.tools.seam.ui.SeamGuiPlugin;
@@ -144,6 +145,8 @@
if(cannotBeModified) {
setEnablement(seamEnablement, false);
setEnablement(runtime, false);
+ } else if(hasDependents(project)) {
+ setEnablement(seamEnablement, false);
}
return composite;
@@ -159,6 +162,27 @@
}
return false;
}
+
+ private boolean hasDependents(IProject p) {
+ ISeamProject sp = SeamCorePlugin.getSeamProject(p, false);
+ if(sp == null) return false;
+ IEclipsePreferences ep = SeamPreferences.getProjectPreferences(sp);
+ if(ep == null) return false;
+ String ear = ep.get("seam.ear.project", null);
+ if(projectExists(ear)) return true;
+ String ejb = ep.get("seam.ejb.project", null);
+ if(projectExists(ejb)) return true;
+ String test = ep.get("seam.test.project", null);
+ if(projectExists(test)) return true;
+ return false;
+ }
+
+ private boolean projectExists(String name) {
+ if(name == null) return false;
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+ if(p != null && p.exists() && p.isAccessible()) return true;
+ return false;
+ }
@Override
public boolean performOk() {
17 years, 3 months