angelozerr / eclipse-wtp-webresources

Provides completion, hyperlink, hover inside WTP HTML editor for Web Resources (CSS, JS, Images)
Eclipse Public License 1.0
13 stars 9 forks source link

No way to dynamically contribute stylesheets to be traversed #4

Closed gamerson closed 10 years ago

gamerson commented 10 years ago

In my use-case, portlets, we have css files that are not imported in a html/jsp via s but instead of included by the portal container on the portlets behalf. I'd like the ability to extend the traversing class with an extension point so that when a user is in a portlet jsp file in a liferay project, and has css files that will be included by the portal (in a liferay-portlet.xml file) then my plugin could automatically add those files to be traversed.

angelozerr commented 10 years ago

I think we should manage CSS import :

gamerson commented 10 years ago

Yes agreed, similar to how tern.java has the script paths per-project, you could per-project set the css paths.

So either one approach would be good enough for our purposes at Liferay.

On Fri, Sep 12, 2014 at 2:57 PM, Angelo notifications@github.com wrote:

I think we should manage CSS import :

  • with extension point.
  • with user preferences by selecting several folders.

— Reply to this email directly or view it on GitHub https://github.com/angelozerr/eclipse-wtp-htmlcss/issues/4#issuecomment-55368001 .

Greg Amerson Liferay Developer Tools Liferay, Inc. www.liferay.com

angelozerr commented 10 years ago

If I provide an extension point, Liferay IDE will be linked a lot of this project. is it not dangerous?

My problem today is the name of the plugin : see my explanation at https://github.com/angelozerr/eclipse-wtp-htmlcss#user-content-why-orgeclipseawsthtmlcssui

kaloyan-raev commented 10 years ago

@angelozerr did you open an Eclipse bug for this sorting issue?

gamerson commented 10 years ago

Well for now it is not a problem but I just hope once this feature is contributed to eclipse there is a way to make it more flexible and I wanted to mention it now.

On Fri, Sep 12, 2014 at 3:22 PM, Angelo notifications@github.com wrote:

If I provide an extension, Liferay IDE will be linked a lot of this project. is it not dangerous?

My problem today is the name of the plugin : see my explanation at https://github.com/angelozerr/eclipse-wtp-htmlcss#user-content-why-orgeclipseawsthtmlcssui

— Reply to this email directly or view it on GitHub https://github.com/angelozerr/eclipse-wtp-htmlcss/issues/4#issuecomment-55369676 .

Greg Amerson Liferay Developer Tools Liferay, Inc. www.liferay.com

angelozerr commented 10 years ago

@angelozerr did you open an Eclipse bug for this sorting issue?

@kaloyan-raev I have created it. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=444189

gamerson commented 10 years ago

Btw, the project container as a default container for possible css files is good enough for my use-case, thanks.

On Tue, Sep 16, 2014 at 4:17 AM, Angelo notifications@github.com wrote:

@angelozerr https://github.com/angelozerr did you open an Eclipse bug for this sorting issue?

@kaloyan-raev https://github.com/kaloyan-raev I have created it. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=444189

— Reply to this email directly or view it on GitHub https://github.com/angelozerr/eclipse-wtp-webresources/issues/4#issuecomment-55651499 .

Greg Amerson Liferay Developer Tools Liferay, Inc. www.liferay.com

angelozerr commented 10 years ago

@gamerson I'm changing that to improve performance. I will explain you more when I will have cleaned my code and commited.

gamerson commented 10 years ago

So will there be a way to contribute other stylesheets that are not even in the project? i.e. with liferay portlets, bootstrap css is available by default, so it would be great if the bootstrap css file could be fed into the proposals.

On Wed, Sep 17, 2014 at 3:49 PM, Angelo notifications@github.com wrote:

@gamerson https://github.com/gamerson I'm changing that to improve performance. I will explain you more when I will have cleaned my code and commited.

— Reply to this email directly or view it on GitHub https://github.com/angelozerr/eclipse-wtp-webresources/issues/4#issuecomment-55860222 .

Greg Amerson Liferay Developer Tools Liferay, Inc. www.liferay.com

angelozerr commented 10 years ago

where comes from bootstrap css ?

gamerson commented 10 years ago

The bootstrap css is coming from inside the liferay portal's root webapp so by the time that the developer's portlet is rendered there is bootstrap css classes available.

On Thu, Sep 18, 2014 at 9:36 PM, Angelo notifications@github.com wrote:

where comes from bootstrap css ?

— Reply to this email directly or view it on GitHub https://github.com/angelozerr/eclipse-wtp-webresources/issues/4#issuecomment-56038724 .

Greg Amerson Liferay Developer Tools Liferay, Inc. www.liferay.com

angelozerr commented 10 years ago

If I unedrstand bootstrap css is not inside workspace. So I suppose you wish to load bootstrap CSS from file system where portal is installed. Is that?

angelozerr commented 10 years ago

If bootstrap css is in your workspace, you can :

package com.liferay.ide.webresources;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.wst.html.webresources.core.WebResourceType;
import org.eclipse.wst.html.webresources.core.providers.AbstractWebResourcesProvider;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;

public class BootstrapCSSProvider extends AbstractWebResourcesProvider {

    @Override
    public IResource[] getResources(IDOMNode htmlNode, IFile htmlFile,
            WebResourceType resourceType) {
        IProject project = htmlFile.getProject();
        IFile f = // use some preferences project to retrieve bootstrap.css =>  project.getFile("bootstrap.css");
        if (f.exists()) {
            IResource[] resources = new IResource[1];
            resources[0] = f;
            return resources;
        }
        return null;
    }
}

Declare extension point like this :

    <extension
              point="org.eclipse.a.wst.html.webresources.core.webResourcesProviders">
     <provider
           class="com.liferay.ide.webresources.BootstrapCSSProvider"
           types="css">
     </provider>
    </extension>
gamerson commented 10 years ago

Thanks for this tip, but the bootstrap files live inside the portal root war. So in order to use this I would have to make a shadow copy of it somewhere in the user's workspace, like in a hidden project with a linked resource or something like that. Thanks.

On Fri, Sep 19, 2014 at 11:25 PM, Angelo notifications@github.com wrote:

If bootstrap css is in your workspace, you can :

package com.liferay.ide.webresources; import org.eclipse.core.resources.IFile;import org.eclipse.core.resources.IProject;import org.eclipse.core.resources.IResource;import org.eclipse.wst.html.webresources.core.WebResourceType;import org.eclipse.wst.html.webresources.core.providers.AbstractWebResourcesProvider;import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; public class BootstrapCSSProvider extends AbstractWebResourcesProvider {

@Override
public IResource[] getResources(IDOMNode htmlNode, IFile htmlFile,
        WebResourceType resourceType) {
    IProject project = htmlFile.getProject();
    IFile f = // use some preferences project to retrieve bootstrap.css =>  project.getFile("bootstrap.css");
    if (f.exists()) {
        IResource[] resources = new IResource[1];
        resources[0] = f;
        return resources;
    }
    return null;
}}

Declare extension point liek this :

<extension
          point="org.eclipse.a.wst.html.webresources.core.webResourcesProviders">
 <provider
       class="com.liferay.ide.webresources.BootstrapCSSProvider"
       types="css">
 </provider>
</extension>

— Reply to this email directly or view it on GitHub https://github.com/angelozerr/eclipse-wtp-webresources/issues/4#issuecomment-56192261 .

Greg Amerson Liferay Developer Tools Liferay, Inc. www.liferay.com

angelozerr commented 10 years ago

@gamerson my question is :

gamerson commented 10 years ago

I can't easily use IResource. The only way for me to use IResource is to copy the real bootstrap files from portal root and copy them into the workspace somewhere (hidden of course) and then get a IResource handler for them.

For me the webResourcesFileSystemProviders would be better as I could directly point to the fileSystem resources.

On Mon, Sep 22, 2014 at 3:23 PM, Angelo notifications@github.com wrote:

@gamerson https://github.com/gamerson my question is :

  • can you use IResource to retrieve bootsrap.css. In this case you can use BootstrapCSSProvider like explained.
  • or do you need retrieve bootsrap.css from FileSystem. So in this case, I must provide a webResourcesFileSystemProviders

— Reply to this email directly or view it on GitHub https://github.com/angelozerr/eclipse-wtp-webresources/issues/4#issuecomment-56337189 .

Greg Amerson Liferay Developer Tools Liferay, Inc. www.liferay.com

angelozerr commented 10 years ago

For me the webResourcesFileSystemProviders would be better as I could directly point to the fileSystem resources.

Ok, but bootstrap.css, is included in a war. So it means that I must unzip the war portal?

gamerson commented 10 years ago

For Liferay IDE most developers point to a portal bundle which has the war pre-installed (exploded) so I can point directly to the portal css files.

On Mon, Sep 22, 2014 at 3:32 PM, Angelo notifications@github.com wrote:

For me the webResourcesFileSystemProviders would be better as I could directly point to the fileSystem resources.

Ok, but bootstrap.css, is included a war. So it means that I must unzip the war portal?

— Reply to this email directly or view it on GitHub https://github.com/angelozerr/eclipse-wtp-webresources/issues/4#issuecomment-56337954 .

Greg Amerson Liferay Developer Tools Liferay, Inc. www.liferay.com

angelozerr commented 10 years ago

See https://github.com/angelozerr/eclipse-wtp-webresources/wiki/webResourcesProviders-Extension-Point

gamerson commented 10 years ago

Sweet, thanks for much Angelo, I'll give this a try soon and let you know the results.

On Tue, Sep 23, 2014 at 12:30 AM, Angelo notifications@github.com wrote:

See https://github.com/angelozerr/eclipse-wtp-webresources/wiki/webResourcesProviders-Extension-Point

— Reply to this email directly or view it on GitHub https://github.com/angelozerr/eclipse-wtp-webresources/issues/4#issuecomment-56400208 .

Greg Amerson Liferay Developer Tools Liferay, Inc. www.liferay.com