Getting colors from current user selected theme - intellij-plugin

I started making an IntelliJ plugin in Java and wanted to know if there is a way to programmatically get certain colors from
the current IDE theme, for example getting the magenta terminal foreground color.
For now I only achieve getting a light color for light theme and dark for dark.
What I aim to is to get precise colors from the user installed color schemes. For instance I use the Atom One Dark theme from the plugin store.
I'm looking to get the colors in the currently selected ColorScheme, all colors from themes are stored into an .icls file by the format :
<option name="CONSOLE_ERROR_OUTPUT">
<value>
<option name="FOREGROUND" value="e06c75" />
</value>
</option>
I'd like to get the color by its name attribute.
Thanks for helping, have a nice day.

you can check class: UIUtil for example UIUtil.getTreeTextBackground() it should return Color

Thank you very much you both lead me in the right direction !
I found just what I was looking for.
You can get my function for collecting color schemes colors at the bottom of this post.
The solution was :
ColorSchemes files or .icls files look like this :
<scheme name="ThemeName" version="142" parent_scheme="Darcula">
<metaInfo>
</metaInfo>
<colors>
<option name="ADDED_LINES_COLOR" value="98c379" />
</colors>
<attributes>
<option name="ABSTRACT_CLASS_NAME_ATTRIBUTES">
<value>
<option name="FOREGROUND" value="e6c07b" />
</value>
</option>
</attributes>
</scheme>
You can get those colors programmatically , in java (sorry I don't know how to do it in Kotlin) you can fetch the current color scheme by doing :
EditorColorsScheme colorsScheme = EditorColorsManager.getInstance().getSchemeForCurrentUITheme();
Or you can get the default color scheme by doing :
EditorColorsScheme colorsScheme = = EditorColorsManager.getInstance().getScheme(EditorColorsManager.getInstance().getAllSchemes()[0].getName());
From that I've made a simple function that can fetch a specific color by its name (attribute and colors). If the name given does not correspond to a color defined in <attributes> it will look in the <colors> section. You can also precise if you specifically want the background color of an attribute.
Here is the function :
public Color fetchIJColor(String name, boolean isBackground){
Color c = colorsScheme.getAttributes(TextAttributesKey.createTextAttributesKey(name)).getForegroundColor();
if(c == null || isBackground){
c = colorsScheme.getAttributes(TextAttributesKey.createTextAttributesKey(name)).getBackgroundColor();
}
if(c == null){
c = colorsScheme.getColor(ColorKey.createColorKey(name));
}
return c;
}

Related

how to customise the bg-color of the menu in elementUI

In elementUI the default background-color is white ; when choosing the them:dark , it is black, but how can I customise the bg-color by myself?
I have tried to add the style property at the el-menu tag , but it didn't work
<el-menu style="{background-color: rgb(36,36,36)!important}"
I try to find the source code of the css file of el-menu tag and I try to change some setting relating to background-color, don't work either
the menu component just like
somebody told me I can code like this
<el-menu style="{backgroundColor: yello}.." but it didn't work
The class for that particular element is not modifiable, have a look:
:class="{
'el-menu--horizontal': mode === 'horizontal',
'el-menu--dark': theme === 'dark',
'el-menu--collapse': collapse
}"
So your choices are:
Wrap it in a custom <div class="my-specific-selector and target it with .my-specific-selector .el-menu
Override the CSS for the dark theme
Copy + paste contents of component into your own file, adjust accordingly, use that instead.
you can try put background color directly like this
<el-menu
background-color="#304156"
text-color="#bfcbd9"
active-text-color="#409EFF"
style="height: 61px;"
></el-menu>

Is there any analog to property binding via fxml in JavaFX?

In JavaFX property can be bound to some observable value.
Label l = new Label();
l.visibleProperty().bind(l.textProperty().length().isEqualTo(3));
l.setText("123"); // show label
l.setText("1234"); // hide label
Recently I have discovered that binding can be done not only in code but in FXML markup document.
<!-- Label is visible only if input is visible. -->
<Label l="Please input some value:" visible="${value.visible}" />
<TextField fx:id="value" />
Is there similar feature in another languages and markup tools or that is kind of oracle innovation? :-)
update: I added XAML tag because I guess it has something similar.
I have found out that QML has the same feature.

Grid error for only one record

I have bug in struts2-grid-Jquery.Every time grid contains only one record ,grid disappear the record as in hyperlink but if there are more than one record it work fine. My code :
<sjg:grid id="gridtable"
dataType="json"
href="%{remoteurl}"
gridModel="allCustomerRequests"
pager="true"
page="1"
rowNum="10"
pagerButtons="true"
pagerInput="true"
gridview="true"
rowTotal="true"
rownumbers="true"
rowList="10,20,30,40,40,50,60,70,80,90,100"
viewrecords="true"
autowidth="true"
loadonce="true"
viewrecords="true"
>
<sjg:gridColumn name="stRefID" formatter="formatViewLink"
title="%{getText('COMMON_REFERENCE_NUMBER')}" />
<sjg:gridColumn name="requestType.stName"
title="%{getText('RequestTracking_Request_Type')}" />
<sjg:gridColumn name="requestStatus.stStatus"
title="%{getText('RequestTracking_Request_Status')}" />
<sjg:gridColumn name="requestStatus.tsDate"
title="%{getText('DATE')}"
formatoptions="{newformat : 'd/m/Y',
srcformat : 'Y-m-d'}" formatter="date" />
</sjg:grid>
Please help me to solve my bug
enter link description here
I m pretty sure you are expriencing this issue with IE...?
It has nothing to do with the grid plugin but the way IE includes the size of scroll bar when calculating height/width.
A workaround for you is to fix the height of your grid using the height attribute of <sjg:grid />.

Google Earth: Retrieving icon URL from KML using JAK

I'm currently using JAK (Java API for KML) to interact with Google Earth and a customized KML file. I'm able to get/set the name, description, coordinates of a placemark using things like Placemark p.getName(), or point.getCoordinates(); into a list, etc. But what I'm having trouble with is getting the url of the image used for the icon. So for example, if my kml file has this placemark in it (contained by a Document, and then the overall KML tag):
<Placemark>
<name>Isla de Roatan</name>
<description>
Cruise Stop
</description>
<Style>
<IconStyle>
<Icon>
<href>http://maps.google.com/mapfiles/kml/shapes/airports.png</href>
</Icon>
</IconStyle>
</Style>
<Point>
<coordinates>-86.53,16.337461,0</coordinates>
</Point>
</Placemark>
How can I grab that png url to say, put in a separate String object? I've seen within Style the .getIconStyle, and within IconStyle, the .getIcon, and within Icon, the .getHttpQuery, but nothing to link looking into the Style from the Placemark/Feature, except for .getStyleSelector and .getStyleUrl. Can you do it with one of those or a Style Map? I'm not sure if I grasp completely what each of these does. Additionally in reverse, what can be done to set this URL? Thanks for any help!
Feature.getStyleSelector() returns a List<StyleSelector>. Style is a subclass of StyleSelector, so your Style should be in this list (along with any other Styles and StyleMaps defined for the Feature).
Setting style (and icon URL):
Placemark placemark = ...;
Style myStyle = new Style().withId("my_style");
myStyle.withIconStyle(new IconStyle().withIcon(new Icon().withHref("http://someurl")));
placemark.addToStyleSelector(myStyle);
Getting style (and icon URL):
for (StyleSelector styleSelector : placemark.getStyleSelector())
{
if (styleSelector.getId() == "my_style")
{
String href = ((Style)styleSelector).getIconStyle().getIcon().getHref();
}
}

A TextBox which will accept specific values via value picker

I have a simple dojo text box and a value picker. I want to disable this field for manual entry so that value picker should be used only.
Normally, I can disable the field with dojo attribute, but it greys out the field which is confusing for the user.
<xe:djTextBox id="dep" value="#{viewScope.Department}">
<xe:this.dojoAttributes>
<xp:dojoAttribute name="readonly" value="true"></xp:dojoAttribute>
</xe:this.dojoAttributes>
</xe:djTextBox>
<xe:valuePicker id="valuePicker1" for="dep" dialogTitle="Select the department">
<xe:this.dataProvider>
<xe:simpleValuePicker valueListSeparator=",">
<xe:this.valueList><![CDATA[#{javascript:#DbColumn("", "(ActiveDepartments)", 1)||""}]]></xe:this.valueList>
</xe:simpleValuePicker>
</xe:this.dataProvider>
</xe:valuePicker>
Any method to achieve this without clientside javascript tricks?
You can change the color of the text by overriding the following CSS:
.dijitTextBoxReadOnly, .dijitTextBoxDisabled {
color: gray;
}
You probably want to set color to black in order for the field not to look disabled :-)