eclipse rcp product set tab style not work - eclipse-rcp

I develop a rcp product with eclipse kepler(Eclipse for RCP and RAP Developers), but set tab style not work.
I tried two ways
1.config.xml
<extension id="product" point="org.eclipse.core.runtime.products">
<product application="cn.desktoptool.application" name="cn.test">
<property name="preferenceCustomization" value="plugin_customization.ini"/>
</product>
and plugin_customization.ini file
org.eclipse.ui/SHOW_TRADITIONAL_STYLE_TABS=false
2.add code in class ApplicationWorkbenchAdvisor
PlatformUI.getPreferenceStore().setValue( IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS, false);
but not work, What's the problem?

This preference is not used in Eclipse 4.3 (Kepler) because the styling is controlled by CSS.
To change the tab style you either define your own style or you can edit one of the existing css files (in the org.eclipse.platform plugin css directory).
The tab style is controlled by the swt-simple property, usually set for the .MPartStack class:
.MPartStack {
swt-simple: true;
.. other properties ...
}
true gives you the traditional tabs.
More information on css styling and creating styles here: http://www.vogella.com/articles/Eclipse4CSS/article.html

Related

Branding of Eclipse view icons

It is possible to change the branding of an Eclipse RCP application with an Eclipse "product". For example, the application icons, splash screen and about box can be changed.
But is it possible to change the icons of other things with some sort of branding mechanism?
It would be of interest to change to icons of the following things:
Views (most important for me!)
Editors
Different kinds of resources (for example, in Project Explorer view)
Toolbar buttons
If it is not possible to change these with some build in branding mechanism, is there any work around? Can this be done programmatically with reasonable effort?
It is possible to locate all brand specific icons to a branding plugin. The icons can then be changed by switching only the branding plugin.
To do this all icons paths must be set to icons in the branding plugin.
This can be achieved using the platform URI scheme in the plugin.xml file. For example:
<view>
...
icon="platform:/plugin/com.app.branding/icons/icon.png"
</view>
Setting icons with platform URI:s is described the answer to this question:
How can I reference an icon from a plugin?

Can the window title include the version number of the core plugin in an Eclipse 4 application with compatibility layer?

In a mixed mode Eclipse RCP application, I'd like to change the application window title to something like "Great App v1.3.22".
I basically have application (3.x based) and product (4.5 (Mars) based) split up into two plugins (following a helpful blog post describing how to use 3.x views in Eclipse 4, I need the CNF).
At the moment, the title is "got" from the org.eclipse.core.runtime.products extension point defined in the product plugin:
<extension
id="my_product_id"
point="org.eclipse.core.runtime.products">
<product
name="Great App"
application="my.application">
</product>
</extension>
Can I use a variable in the <product name> property? If so, what variables are available? Or can this be achieved by "overriding" the window title via the Trimmed Window entry in Application.e4xmi, and again what variables would be available? Or do I have to resort to ancient ways and set the title programmatically in the old ApplicationWorkbenchWindowAdvisor (which, however, wouldn't be available if I was able to switch to a pure E4 app once the CNF is available as a native E4 plugin)?
There are no variables you can use.
You can change the main window title in the LifeCycle class. The #ProcessAdditions method is the earliest you can do this:
#ProcessAdditions
public void processAdditions(MApplication app, EModelService modelService, IApplicationContext applicationContext)
{
MWindow window = (MWindow)modelService.find("id of main trimmed window", app);
window.setLabel("new text");
}
I am not sure where you want to get the version from. One possibility is a property in the product definition:
<extension
id="my_product_id"
point="org.eclipse.core.runtime.products">
<product
name="Great App"
application="my.application">
<property
name="version"
value="1.3.22">
</property>
</product>
</extension>
You will have to maintain this property manually or do something in your build to set it.
You can access this using the IApplicationContext
applicationContext.getBrandingProperty("version")

Override builtin perspective layout in Eclipse-RCP product

Is it possible to override the layout of a built-in perspective in my Eclipse-RCP product?
In particular, I wish to add a custom view and change the layout of the Debug perspective. I know how to do it with a custom perspective (IPerspectiveFactory.createInitialLayout()). I'd want that my custom layout to be permanent -survive the "Reset perspective" command.
Create a class that implements IPerspectiveFactory.
Add a perspectives extension to your plugin.xml. Here's one of mine.
<extension point="org.eclipse.ui.perspectives">
<perspective
class="gov.bop.cobolsupport.perspectives.CobolPerspectiveFactory"
icon="icons/ispf_editor.gif"
id="gov.bop.cobolsupport.CobolPerspective"
name="Cobol"/>
</extension>
Your users can change your perspective, and save their changes if they wish. That's built into Eclipse.
However, when you extend your perspective, the Reset Perspective command resets the perspective to how you defined it in your Perspectivefactory class.
Extending a perspective is possible by using the extension point org.eclipse.ui.perspectiveExtensions.
Plug-ins can add their own action sets, views, and various shortcuts
to existing perspectives by contributing to the
org.eclipse.ui.perspectiveExtensions extension point.
To extend the default debug perspective paste the following code in your plugin.xml:
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="org.eclipse.debug.ui.DebugPerspective">
<view
ratio="0.5"
relative="org.eclipse.ui.views.TaskList"
relationship="right"
id="com.jens.customdebug.views.SampleView">
</view>
</perspectiveExtension>
</extension>
You have to define a relative view (in my case the task view named org.eclipse.ui.views.TaskList) and the id of your own view (in my case com.jens.customdebug.views.SampleView)
Source:
To get further information how to use this extension point, take a look here.
For the configuration markup of this extension point you may also take a look at this page.

Very large tabs in Eclipse panes on Ubuntu

My question is very similar to Stack Overflow question Gigantic Tabs in Eclipse on Ubuntu.
I have tried the solutions presented, but they appear to be old. I have found a solution that nicely handles the toolbar and menus, but not a solution that reduces the size and padding of the disproportionately large tabs (and label) within the panes (see the tab "Package Explorer" in the screen below).
I am happy with the way my OS-wide GTK theme is customized and don't want to change that. Is there a quick fix to reduce the tab sizes of the panes in Eclipse?
I'm using Eclipse for Mobile Developers (Juno) on Ubuntu 12.04. I'll also mention that I really like the way Eclipse appears out of the box in Windows 7, so something similar to that would be ideal.
Here are the eclipse specific GTK styles I'm using:
style "eclin" {
GtkButton::default_border={1,1,1,1}
GtkButton::default_outside_border={1,1,1,1}
GtkButtonBox::child_min_width=0
GtkButtonBox::child_min_heigth=0
GtkButtonBox::child_internal_pad_x=0
GtkButtonBox::child_internal_pad_y=0
GtkMenu::vertical-padding=1
GtkMenuBar::internal_padding=1
GtkMenuItem::horizontal_padding=4
GtkToolbar::internal-padding=1
GtkToolbar::space-size=1
GtkOptionMenu::indicator_size=0
GtkOptionMenu::indicator_spacing=0
GtkPaned::handle_size=4
GtkRange::trough_border=0
GtkRange::stepper_spacing=0
GtkScale::value_spacing=0
GtkScrolledWindow::scrollbar_spacing=0
GtkExpander::expander_size=10
GtkExpander::expander_spacing=0
GtkTreeView::vertical-separator=0
GtkTreeView::horizontal-separator=0
GtkTreeView::expander-size=12
GtkTreeView::fixed-height-mode=TRUE
GtkWidget::focus_padding=0
font_name="Liberation Sans,Sans Regular 8"
}
class "GtkWidget" style "eclin"
style "eclin2" {
xthickness=1
ythickness=1
}
class "GtkButton" style "eclin2"
class "GtkToolbar" style "eclin2"
class "GtkPaned" style "eclin2"
Here is a screenshot of what my IDE looks like with the huge tabs:
You can edit Eclipse's CSS instead of messing with the GTK theme.
In your Eclipse directory find the file plugins/org.eclipse.platform_4.2.*/css/e4_default_gtk.css (there's an * in there, because I guess that the version may change in the future or may be different already). In this file there's a CSS class:
.MPartStack {
font-size: 11;
swt-simple: false;
swt-mru-visible: false;
}
And you have two possible solutions:
change font-size to something smaller
just comment out or remove font-size from this class (works well for me)
And that should do the trick.
Style of tabs can be changed in Eclipse 4.2 by editing CSS. You can change styles directly in Eclipse Preferences window after installing the E4 CSS editor plug-in.
Go to menu Help > Install new software, then install E4 CSS editor (Incubation) plug-in using Eclipse 4 update site (add this link: http://download.eclipse.org/e4/updates/0.12).
After restart, go to Window > Preferences, General > Appearance and now you can edit styles here for any selected theme.
I am using this style for tabs:
.MPartStack {
font-size: 9;
font-family: Liberation Sans;
swt-tab-renderer: null;
swt-tab-height: 22px;
swt-selected-tabs-background: #FFFFFF #ECE9D8 100%;
swt-simple: false;
swt-mru-visible: false;
}
You can specify tabs height using the swt-tab-height option. It's value sets tab height ignoring the font size.
I also wanted to reduce especially the horizontal space in order to fit more tabs, as Eclipse lacks multi-row tabs.
These instructions will go for any platform (not limited to e.g. Ubuntu/GTK).
What I did was:
Reduced the font size
Changed font to something horizontal-compact
Removed the X (close tab) button
...yielding the following result on my system (Win 7):
...and this is how it's done:
Check what CSS layout you're using: Preferences->General->Appearance-> check value of 'Theme:' listbox
Open the corresponding file in <eclipse folder>\plugins\org.eclipse.platform_<your version>\css, e.g. e4_default_win7.css
Modify .MPartStack entries to set font size and font, e.g.:
.MPartStack {
font-size: 8;
font-family: 'Arial Narrow';
swt-simple: true;
swt-mru-visible: false;
}
Add the following entry to remove the X (close icon):
CTabItem {
swt-show-close: false !important;
}
That's it!
Eclipse is now (4.5 Mars) defaulting to GTK3 on Linux. For 4.6 a fix seems to be alredy merged.
Changing SWT_GTK3 environment variable works for Eclipse Mars:
$ export SWT_GTK3=0
or set that variable inline with running eclipse
$ SWT_GTK3=0 /path/to/eclipse/eclipse
To kill it dead just drop this in the root as eclipse.sh:
#!/bin/bash
SWT_GTK3=0 exec env "${0%.sh}"
You may try the theme from https://github.com/jeeeyul/eclipse-themes.
After install this theme, apply it by choosing the theme in Window > Preferences > General > Appearence > Jeeeyul's themes.
And to solve the large tab problem, please refer to https://github.com/jeeeyul/eclipse-themes/wiki/Linux-Huge-Toolbar-Problem.
It's easy and beatiful. Enjoy it!
An alternative way is to select:
System settings > Universal access > Text size as small.
You can edit all small details about tab size here:

How do I change the background color of the Navigator view in eclipse?

I didn't find any option for that, so I suspect that some views follow the color pattern of the operating system. I'm currently using OS X, and it seems like changing the default background color it's not possible either.
What I'm trying to accomplish is to create a dark background theme, but customization seems only possible on some of the eclipse views.
For platforms where eclipse uses gtk (Linux for example) one can use a custom gtkrc file (place it for example in the eclipse base directory)
style "eclipse" {
base[NORMAL] = "#FDF6E3"
fg[SELECTED] = "#FDF6E3"
base[SELECTED] = "#073642"
fg[NORMAL] = "#073642"
text[NORMAL] = "#073642"
base[ACTIVE] = "#073642"
}
class "GtkWidget" style "eclipse"
And a custom start script for eclipse
#!/bin/sh
GTK2_RC_FILES=gtkrc ./eclipse
Got the solution from http://blog.sarathonline.com/2008/10/solved-eclipse-looks-good-in-ubuntu-now.html
Combine this with the color themes plugin for coloring the editors
My case is: Eclipse ver. 2018-09, Win 10.
Eclipse install folder: C:\eclipse\eclipse-2018-09
I compared 2 files:
1) C:\eclipse\eclipse-2018-09\plugins\org.eclipse.ui.themes_1.2.200.v20180828-1350\css\e4_basestyle.css
2) C:\eclipse\eclipse-2018-09\plugins\org.eclipse.ui.themes_1.2.200.v20180828-1350\css\e4-dark.css
And find out css selector "CTabFolder Tree, CTabFolder Canvas" is present in dark, but absent in basestyle.
Add this selector in file "e4_basestyle.css"
CTabFolder Tree, CTabFolder Canvas {
background-color: #dddddd;
color: #000;
}
and You can tune color for nav view.
Then select theme "Light" in Preferences->General->Appearance and click "Apply".
As mentioned in "Changing UI color in Eclipse":
Each time you see white or gray color, this is more than likely related to OS system colors.
(that is, for everything which is not an editor or a custom view).
This is likely the case for the navigator view, as reminded in "How to change background of all VIEWS in Eclipse IDE ?"
When Git is present, Project Explorer colors can be altered via Preferences > General > Apparearance > Colors and Fonts > Git