Che: Change title of tab

Created on 30 May 2017  路  2Comments  路  Source: eclipse/che

Hello,

I'm currently trying to change the title of a tab (CHE 5.10.0).

I have for example this project:
image
and when I open the file README, I got this:
image

Is there a simple way to change the title of the tab without modifying the existing CHE source code, with an extension for example ?

kinquestion

Most helpful comment

Hi, @vnea! You can create an implementation of org.eclipse.che.ide.api.resources.ResourceInterceptor for this purpose.

See example:

import com.google.inject.Singleton;

import org.eclipse.che.ide.api.resources.Resource;
import org.eclipse.che.ide.api.resources.ResourceInterceptor;
import org.eclipse.che.ide.api.resources.marker.PresentableTextMarker;

@Singleton
public class CustomResourceInterceptor implements ResourceInterceptor {

    public static final String README = "README";

    @Override
    public void intercept(Resource resource) {

        // or by specific path resource.getLocation().equals(Path.valueOf("/ChangeTabTitle/README"))

        if (resource.isFile() && README.equals(resource.getName())) {
            resource.addMarker(new PresentableTextMarker("custom_title"));
        }
    }
}

Then register this interceptor in your gin module:

@ExtensionGinModule
public class MavenGinModule extends AbstractGinModule {

    @Override
    protected void configure() {
        // ...
        GinMultibinder.newSetBinder(binder(), ResourceInterceptor.class).addBinding().to(CustomResourceInterceptor.class);
        // ...
    }
}

And you'll have smth like that:
eclipse che

All 2 comments

Hi, @vnea! You can create an implementation of org.eclipse.che.ide.api.resources.ResourceInterceptor for this purpose.

See example:

import com.google.inject.Singleton;

import org.eclipse.che.ide.api.resources.Resource;
import org.eclipse.che.ide.api.resources.ResourceInterceptor;
import org.eclipse.che.ide.api.resources.marker.PresentableTextMarker;

@Singleton
public class CustomResourceInterceptor implements ResourceInterceptor {

    public static final String README = "README";

    @Override
    public void intercept(Resource resource) {

        // or by specific path resource.getLocation().equals(Path.valueOf("/ChangeTabTitle/README"))

        if (resource.isFile() && README.equals(resource.getName())) {
            resource.addMarker(new PresentableTextMarker("custom_title"));
        }
    }
}

Then register this interceptor in your gin module:

@ExtensionGinModule
public class MavenGinModule extends AbstractGinModule {

    @Override
    protected void configure() {
        // ...
        GinMultibinder.newSetBinder(binder(), ResourceInterceptor.class).addBinding().to(CustomResourceInterceptor.class);
        // ...
    }
}

And you'll have smth like that:
eclipse che

@vzhukovskii Thank it works perfectly !

Was this page helpful?
0 / 5 - 0 ratings