Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2013-07-15 17:53:47 -0400
committerTom Schindl2013-07-15 17:53:47 -0400
commitd02323875b1c483693edaf0342114b2ed481c4f0 (patch)
tree72d617678b9e4fc2ec33842a951fbf7109058b98
parent06bf7142f35c1a9bc7dca371528cbe79e570cf82 (diff)
downloadorg.eclipse.efxclipse-d02323875b1c483693edaf0342114b2ed481c4f0.tar.gz
org.eclipse.efxclipse-d02323875b1c483693edaf0342114b2ed481c4f0.tar.xz
org.eclipse.efxclipse-d02323875b1c483693edaf0342114b2ed481c4f0.zip
Bug 411660 - [css] Need support different JavaFX versions
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.css.cssext.ui/OSGI-INF/cssExtProvider.xml1
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.css.cssext.ui/src/org/eclipse/fx/ide/css/cssext/ui/CssExtManager.java100
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.css.cssext.ui/src/org/eclipse/fx/ide/css/cssext/ui/internal/DefaultCssExtProvider.java10
-rw-r--r--[-rwxr-xr-x]bundles/tooling/org.eclipse.fx.ide.css.cssext/src/org/eclipse/fx/ide/css/cssext/ICSSExtModelProvider.java (renamed from bundles/tooling/org.eclipse.fx.ide.css.jfx/src/dummy.java)16
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.css.cssext/src/org/eclipse/fx/ide/css/cssext/ICssExtManager.java3
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.css.jfx/META-INF/MANIFEST.MF9
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.css.jfx/OSGI-INF/jfx2.cssext2
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.css.jfx/OSGI-INF/jfx8.cssext2
-rw-r--r--bundles/tooling/org.eclipse.fx.ide.css.jfx/OSGI-INF/jfxprovider.xml8
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.css.jfx/build.properties3
-rw-r--r--bundles/tooling/org.eclipse.fx.ide.css.jfx/src/org/eclipse/fx/ide/css/jfx/JFXModelProvider.java104
11 files changed, 202 insertions, 56 deletions
diff --git a/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/OSGI-INF/cssExtProvider.xml b/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/OSGI-INF/cssExtProvider.xml
index bea1a9a14..287877ffa 100755
--- a/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/OSGI-INF/cssExtProvider.xml
+++ b/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/OSGI-INF/cssExtProvider.xml
@@ -5,4 +5,5 @@
<provide interface="org.eclipse.fx.ide.css.extapi.CssExt"/>
</service>
<reference bind="bindCssExtProposalContributor" cardinality="0..n" interface="org.eclipse.fx.ide.css.cssext.proposal.CssExtProposalContributor" name="CssExtProposalContributor" policy="dynamic" unbind="unbindCssExtProposalContributor"/>
+ <reference bind="bindCssExtensionModelProvider" cardinality="0..n" interface="org.eclipse.fx.ide.css.cssext.ICSSExtModelProvider" name="ICSSExtModelProvider" policy="dynamic" unbind="unbindCssExtensionModelProvider"/>
</scr:component>
diff --git a/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/src/org/eclipse/fx/ide/css/cssext/ui/CssExtManager.java b/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/src/org/eclipse/fx/ide/css/cssext/ui/CssExtManager.java
index 74730d09d..dbd8f7a59 100755
--- a/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/src/org/eclipse/fx/ide/css/cssext/ui/CssExtManager.java
+++ b/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/src/org/eclipse/fx/ide/css/cssext/ui/CssExtManager.java
@@ -27,6 +27,7 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.fx.core.log.Log;
import org.eclipse.fx.core.log.Logger;
+import org.eclipse.fx.ide.css.cssext.ICSSExtModelProvider;
import org.eclipse.fx.ide.css.cssext.ICssExtManager;
import org.eclipse.fx.ide.css.cssext.proposal.CssExtProposalContributor;
import org.eclipse.fx.ide.css.cssext.ui.SearchHelper.ElementDefinitionFilter;
@@ -54,56 +55,54 @@ public class CssExtManager implements ICssExtManager {
private @Log("cssext.manager") Logger logger;
private List<CssExtProposalContributor> proposalContributors = new ArrayList<>();
+ private List<ICSSExtModelProvider> extensionModelProvider = new ArrayList<ICSSExtModelProvider>();
- private static void log(String string) {
- System.err.println("MANAGER: " + string);
- }
- private static void logf(String format, Object...args) {
- System.err.printf("MANAGER: " + format , args);
- System.err.println();
- }
-
- private enum FixedExtensions {
- JavaFX2(URI.createPlatformPluginURI("/org.eclipse.fx.ide.css.jfx/OSGI-INF/jfx2.cssext", true));
- public final URI uri;
- private FixedExtensions(URI uri) {
- this.uri = uri;
- }
- }
+// private static void log(String string) {
+// System.err.println("MANAGER: " + string);
+// }
+// private static void logf(String format, Object...args) {
+// System.err.printf("MANAGER: " + format , args);
+// System.err.println();
+// }
+//
+// private enum FixedExtensions {
+// JavaFX2(URI.createPlatformPluginURI("/org.eclipse.fx.ide.css.jfx/OSGI-INF/jfx2.cssext", true));
+// public final URI uri;
+// private FixedExtensions(URI uri) {
+// this.uri = uri;
+// }
+// }
- private Set<CssExtension> model = new HashSet<CssExtension>();
+// private Set<CssExtension> model = new HashSet<CssExtension>();
private boolean loaded = false;
static int count = 0;
public CssExtManager() {
- logf("Ext Manager #%d" ,++count);
- // load javafx2
+// logger.debugf("Ext Manager #%d" ,++count);
}
- public void registerExtenstion(URI uri) {
- logf("loading %s", uri);
- ResourceSet rs = new ResourceSetImpl();
- Resource resource = rs.getResource(FixedExtensions.JavaFX2.uri, true);
- CssExtension model = (CssExtension) resource.getContents().get(0);
-
- this.model.add(model);
- }
-
- public void load() {
- if (loaded) return;
- registerExtenstion(FixedExtensions.JavaFX2.uri);
- loaded = true;
- }
+// public void registerExtenstion(URI uri) {
+// logf("loading %s", uri);
+// ResourceSet rs = new ResourceSetImpl();
+// Resource resource = rs.getResource(FixedExtensions.JavaFX2.uri, true);
+// CssExtension model = (CssExtension) resource.getContents().get(0);
+//
+// this.model.add(model);
+// }
+//
+// public void load() {
+// if (loaded) return;
+// registerExtenstion(FixedExtensions.JavaFX2.uri);
+// loaded = true;
+// }
/* (non-Javadoc)
* @see org.eclipse.fx.ide.css.cssext.ui.ICssExtManager#findPropertyByName(java.lang.String)
*/
@Override
public PropertyDefinition findPropertyByName(IFile f, final String propertyName) {
- load();
-
- List<PropertyDefinition> search = new SearchHelper(model).findPropertiesByFilter(new PropertyDefinitionFilter() {
+ List<PropertyDefinition> search = new SearchHelper(collectModels(f)).findPropertiesByFilter(new PropertyDefinitionFilter() {
@Override
public boolean returnOnFirstHit() {
@@ -154,7 +153,7 @@ public class CssExtManager implements ICssExtManager {
Queue<ElementDefinition> superElements = new LinkedList<>();
- superElements.addAll(new SearchHelper(model).findObjects(new SearchFilter<ElementDefinition>() {
+ superElements.addAll(new SearchHelper(collectModels(f)).findObjects(new SearchFilter<ElementDefinition>() {
@Override
public Class<ElementDefinition> getSearchClass() {
return ElementDefinition.class;
@@ -201,8 +200,7 @@ public class CssExtManager implements ICssExtManager {
@Override
public List<PropertyDefinition> findAllProperties(IFile f) {
- load();
- List<PropertyDefinition> defs = new SearchHelper(model).findPropertiesByFilter(new PropertyDefinitionFilter() {
+ List<PropertyDefinition> defs = new SearchHelper(collectModels(f)).findPropertiesByFilter(new PropertyDefinitionFilter() {
@Override
public boolean returnOnFirstHit() {
@@ -219,9 +217,7 @@ public class CssExtManager implements ICssExtManager {
@Override
public ElementDefinition findElementByName(IFile f, final String elName) {
- load();
-
- List<ElementDefinition> search = new SearchHelper(model).findObjects(new SearchFilter<ElementDefinition>() {
+ List<ElementDefinition> search = new SearchHelper(collectModels(f)).findObjects(new SearchFilter<ElementDefinition>() {
@Override
public Class<ElementDefinition> getSearchClass() {
@@ -244,9 +240,7 @@ public class CssExtManager implements ICssExtManager {
@Override
public ElementDefinition findElementByStyleClass(IFile f, final String styleClass) {
- load();
-
- List<ElementDefinition> r = new SearchHelper(model).findObjects(new SearchFilter<ElementDefinition>() {
+ List<ElementDefinition> r = new SearchHelper(collectModels(f)).findObjects(new SearchFilter<ElementDefinition>() {
@Override
public Class<ElementDefinition> getSearchClass() {
return ElementDefinition.class;
@@ -330,4 +324,22 @@ public class CssExtManager implements ICssExtManager {
return result;
}
+
+ @Override
+ public void addCssExtensionModelProvider(ICSSExtModelProvider p) {
+ extensionModelProvider.add(p);
+ }
+
+ @Override
+ public void removeCssExtensionModelProvider(ICSSExtModelProvider p) {
+ extensionModelProvider.remove(p);
+ }
+
+ private Set<CssExtension> collectModels(IFile file) {
+ Set<CssExtension> rv = new HashSet<>();
+ for( ICSSExtModelProvider p : extensionModelProvider ) {
+ rv.addAll(p.getModels(file));
+ }
+ return rv;
+ }
}
diff --git a/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/src/org/eclipse/fx/ide/css/cssext/ui/internal/DefaultCssExtProvider.java b/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/src/org/eclipse/fx/ide/css/cssext/ui/internal/DefaultCssExtProvider.java
index b7c57a858..902916589 100755
--- a/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/src/org/eclipse/fx/ide/css/cssext/ui/internal/DefaultCssExtProvider.java
+++ b/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/src/org/eclipse/fx/ide/css/cssext/ui/internal/DefaultCssExtProvider.java
@@ -5,6 +5,7 @@ import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.fx.ide.css.cssext.ICSSExtModelProvider;
import org.eclipse.fx.ide.css.cssext.ICssExtManager;
import org.eclipse.fx.ide.css.cssext.parser.CssExtParser;
import org.eclipse.fx.ide.css.cssext.proposal.CssExtProposalContributor;
@@ -124,5 +125,12 @@ public class DefaultCssExtProvider implements CssExt {
public void unbindCssExtProposalContributor(CssExtProposalContributor c) {
cssExtManager.removeCssExtProposalContributer(c);
}
-
+
+ public void bindCssExtensionModelProvider(ICSSExtModelProvider p) {
+ cssExtManager.addCssExtensionModelProvider(p);
+ }
+
+ public void unbindCssExtensionModelProvider(ICSSExtModelProvider p) {
+ cssExtManager.removeCssExtensionModelProvider(p);
+ }
}
diff --git a/bundles/tooling/org.eclipse.fx.ide.css.jfx/src/dummy.java b/bundles/tooling/org.eclipse.fx.ide.css.cssext/src/org/eclipse/fx/ide/css/cssext/ICSSExtModelProvider.java
index 818cb5b8c..c76395abb 100755..100644
--- a/bundles/tooling/org.eclipse.fx.ide.css.jfx/src/dummy.java
+++ b/bundles/tooling/org.eclipse.fx.ide.css.cssext/src/org/eclipse/fx/ide/css/cssext/ICSSExtModelProvider.java
@@ -1,18 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2011 BestSolution.at and others.
+ * Copyright (c) 2013 BestSolution.at and others.
* All rights reserved. This program and the accompanying materials
* are 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:
- * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
*******************************************************************************/
+package org.eclipse.fx.ide.css.cssext;
-/**
- * @author tomschindl
- *
- */
-public class dummy {
+import java.util.Collection;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.fx.ide.css.cssext.cssExtDsl.CssExtension;
+public interface ICSSExtModelProvider {
+ public Collection<CssExtension> getModels(IFile file);
}
diff --git a/bundles/tooling/org.eclipse.fx.ide.css.cssext/src/org/eclipse/fx/ide/css/cssext/ICssExtManager.java b/bundles/tooling/org.eclipse.fx.ide.css.cssext/src/org/eclipse/fx/ide/css/cssext/ICssExtManager.java
index 9ace1e234..cabf1bda2 100755
--- a/bundles/tooling/org.eclipse.fx.ide.css.cssext/src/org/eclipse/fx/ide/css/cssext/ICssExtManager.java
+++ b/bundles/tooling/org.eclipse.fx.ide.css.cssext/src/org/eclipse/fx/ide/css/cssext/ICssExtManager.java
@@ -35,5 +35,8 @@ public interface ICssExtManager {
public abstract void addCssExtProposalContributer(CssExtProposalContributor c);
public abstract void removeCssExtProposalContributer(CssExtProposalContributor c);
+ public void addCssExtensionModelProvider(ICSSExtModelProvider p);
+ public void removeCssExtensionModelProvider(ICSSExtModelProvider p);
+
public List<Proposal> getContributedProposalsForRule(IFile f, String fqRuleName);
} \ No newline at end of file
diff --git a/bundles/tooling/org.eclipse.fx.ide.css.jfx/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.css.jfx/META-INF/MANIFEST.MF
index c918d9fff..3b09f7cf2 100755
--- a/bundles/tooling/org.eclipse.fx.ide.css.jfx/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.css.jfx/META-INF/MANIFEST.MF
@@ -7,6 +7,13 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Require-Bundle: org.eclipse.fx.ide.css.ui;bundle-version="0.8.1",
org.eclipse.swt;bundle-version="3.7.0",
org.eclipse.ui;bundle-version="3.7.0",
- org.eclipse.osgi;bundle-version="3.7.0"
+ org.eclipse.osgi;bundle-version="3.7.0",
+ org.eclipse.fx.ide.css.cssext;bundle-version="0.8.1",
+ org.eclipse.core.resources;bundle-version="3.8.100",
+ org.eclipse.core.runtime;bundle-version="3.9.0",
+ org.eclipse.jdt.core;bundle-version="3.9.0",
+ org.eclipse.jdt.launching;bundle-version="3.7.0",
+ org.eclipse.fx.core;bundle-version="0.8.1"
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Bundle-Vendor
+Service-Component: OSGI-INF/jfxprovider.xml
diff --git a/bundles/tooling/org.eclipse.fx.ide.css.jfx/OSGI-INF/jfx2.cssext b/bundles/tooling/org.eclipse.fx.ide.css.jfx/OSGI-INF/jfx2.cssext
index a72907cba..7a7b8f711 100755
--- a/bundles/tooling/org.eclipse.fx.ide.css.jfx/OSGI-INF/jfx2.cssext
+++ b/bundles/tooling/org.eclipse.fx.ide.css.jfx/OSGI-INF/jfx2.cssext
@@ -1697,7 +1697,7 @@ package javafx {
* common user interactions in a manner which is consistent and predictable
* for the user.
*/
- Control extends layout.Region {
+ Control extends Parent {
/**
* The class name of the Control's Skin.
*/
diff --git a/bundles/tooling/org.eclipse.fx.ide.css.jfx/OSGI-INF/jfx8.cssext b/bundles/tooling/org.eclipse.fx.ide.css.jfx/OSGI-INF/jfx8.cssext
index 7a7b8f711..a72907cba 100755
--- a/bundles/tooling/org.eclipse.fx.ide.css.jfx/OSGI-INF/jfx8.cssext
+++ b/bundles/tooling/org.eclipse.fx.ide.css.jfx/OSGI-INF/jfx8.cssext
@@ -1697,7 +1697,7 @@ package javafx {
* common user interactions in a manner which is consistent and predictable
* for the user.
*/
- Control extends Parent {
+ Control extends layout.Region {
/**
* The class name of the Control's Skin.
*/
diff --git a/bundles/tooling/org.eclipse.fx.ide.css.jfx/OSGI-INF/jfxprovider.xml b/bundles/tooling/org.eclipse.fx.ide.css.jfx/OSGI-INF/jfxprovider.xml
new file mode 100644
index 000000000..896281996
--- /dev/null
+++ b/bundles/tooling/org.eclipse.fx.ide.css.jfx/OSGI-INF/jfxprovider.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.fx.ide.css.jfx.jfxprovider">
+ <implementation class="org.eclipse.fx.ide.css.jfx.JFXModelProvider"/>
+ <service>
+ <provide interface="org.eclipse.fx.ide.css.cssext.ICSSExtModelProvider"/>
+ </service>
+ <reference bind="bindLoggerFactory" cardinality="1..1" interface="org.eclipse.fx.core.log.LoggerFactory" name="LoggerFactory" policy="dynamic" unbind="unbindLoggerFactory"/>
+</scr:component>
diff --git a/bundles/tooling/org.eclipse.fx.ide.css.jfx/build.properties b/bundles/tooling/org.eclipse.fx.ide.css.jfx/build.properties
index 1e68d6ddd..e0ef0910e 100755
--- a/bundles/tooling/org.eclipse.fx.ide.css.jfx/build.properties
+++ b/bundles/tooling/org.eclipse.fx.ide.css.jfx/build.properties
@@ -2,5 +2,6 @@ output.. = bin/
bin.includes = META-INF/,\
.,\
about.html,\
- OSGI-INF/
+ OSGI-INF/,\
+ OSGI-INF/jfxprovider.xml
source.. = src/
diff --git a/bundles/tooling/org.eclipse.fx.ide.css.jfx/src/org/eclipse/fx/ide/css/jfx/JFXModelProvider.java b/bundles/tooling/org.eclipse.fx.ide.css.jfx/src/org/eclipse/fx/ide/css/jfx/JFXModelProvider.java
new file mode 100644
index 000000000..04a4f444a
--- /dev/null
+++ b/bundles/tooling/org.eclipse.fx.ide.css.jfx/src/org/eclipse/fx/ide/css/jfx/JFXModelProvider.java
@@ -0,0 +1,104 @@
+package org.eclipse.fx.ide.css.jfx;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.fx.core.log.Logger;
+import org.eclipse.fx.core.log.LoggerFactory;
+import org.eclipse.fx.ide.css.cssext.ICSSExtModelProvider;
+import org.eclipse.fx.ide.css.cssext.cssExtDsl.CssExtension;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jdt.launching.LibraryLocation;
+
+public class JFXModelProvider implements ICSSExtModelProvider {
+ private CssExtension jfx2Model;
+ private CssExtension jfx8Model;
+ private Map<IVMInstall, Boolean> JDK8CACHE = new HashMap<>();
+ private Logger logger;
+
+ @Override
+ public Collection<CssExtension> getModels(IFile file) {
+ try {
+ if( ! isJDTProject(file.getProject()) ) {
+ return Collections.emptySet();
+ }
+
+ //TODO Check if it is a web project
+
+ IJavaProject jp = JavaCore.create(file.getProject());
+ IVMInstall i = JavaRuntime.getVMInstall(jp);
+
+ if( i == null ) {
+ i = JavaRuntime.getDefaultVMInstall();
+ }
+
+ if( isJava8(i) ) {
+ if( jfx2Model == null ) {
+ jfx2Model = loadModel("jfx2");
+ }
+
+ return Collections.singleton(jfx2Model);
+ } else {
+ if( jfx8Model == null ) {
+ jfx8Model = loadModel("jfx8");
+ }
+
+ return Collections.singleton(jfx8Model);
+ }
+
+ } catch (CoreException e) {
+ logger.error("Failed to extract JDT informations", e);
+ }
+
+ return Collections.emptySet();
+ }
+
+ private boolean isJava8(IVMInstall i) {
+ Boolean rv = JDK8CACHE.get(i);
+ if( rv != null ) {
+ return rv;
+ }
+
+ for( LibraryLocation l : JavaRuntime.getLibraryLocations(i) ) {
+ if( "jfxrt.jar".equals(l.getSystemLibraryPath().lastSegment()) ) {
+ JDK8CACHE.put(i, Boolean.TRUE);
+ return true;
+ }
+ }
+ JDK8CACHE.put(i, Boolean.FALSE);
+ return false;
+ }
+
+ private boolean isJDTProject(IProject p) throws CoreException {
+ return p.getNature(JavaCore.NATURE_ID) != null;
+ }
+
+ private CssExtension loadModel(String name) {
+ URI uri = URI.createPlatformPluginURI("/org.eclipse.fx.ide.css.jfx/OSGI-INF/"+name+".cssext", true);
+
+ ResourceSet rs = new ResourceSetImpl();
+ Resource resource = rs.getResource(uri, true);
+ CssExtension model = (CssExtension) resource.getContents().get(0);
+ return model;
+ }
+
+ public void bindLoggerFactory(LoggerFactory factory) {
+ logger = factory.createLogger(getClass().getName());
+ }
+
+ public void unbindLoggerFactory(LoggerFactory factory) {
+ logger = null;
+ }
+}

Back to the top